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.
BY Best Interview Question ON 25 May 2020

Example

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