Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

142
Visualizações
How to Properly handle errors with ErrorHandler in Angular

I created a class that implements ErrorHandler :

@Injectable()
export class GlobalErrorHandler implements ErrorHandler {
    
    constructor(
        private errorsService: ErrorsService
        ) { }
  
    handleError(error: any) {
        const errorParsed: ParsedError = this.errorsService.getError(error);
    }
}

In my error service, I managed to get the error message, stacktrace and status code of the error catched by my handleError method, and I want to show a custom error message to my user, depending on the error raised.

My problem, is that I dont know how to identify an error when it is catched by my ErrorHandler. Is there a way to manage that ? Every documentations I found on the subject just copy/paste the error message to the User. The problem is that most of the time, the error is not diggest/comprehensible by the user.

Should I keep using try/catch blocks locally to know where the error was thrown and write the message I want, or is there a way to identify the error (by using a unique error code by error ?).

Is there a good way to manage error handling ?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda