1.

How to handle HTTP error response in Angular 4?

Answer»

Here are the best practices for HTTP error handling on Angular:

  • USING a client-side solution for error handling, like HTTPClient or HTTPInterceptor
  • Using Rollbar to effectively track ERRORS.
  • Viewing the errors on Rollbar.
Example

class MyErrorHandler IMPLEMENTS ErrorHandler {
    handleError(error) {
       // do something with the exception
    }
}
@NgModule({
    providers: [{PROVIDE: ErrorHandler, useClass: MyErrorHandler}]
})
class MyModule {}



Discussion

No Comment Found