Skip to content

Instantly share code, notes, and snippets.

@rgabaydullov
Created August 25, 2020 09:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgabaydullov/81cdd60408c0d984a16ded9f3c9d0ccb to your computer and use it in GitHub Desktop.
Save rgabaydullov/81cdd60408c0d984a16ded9f3c9d0ccb to your computer and use it in GitHub Desktop.
Angular error handling example
import { NgModule, Errorhandler } from '@angular/core';
@Injectable
export class CustomErrorHandler extends ErrorHandler {
handleError(error) {
return middlewareErrorHandler(error);
}
}
// ...
@NgModule({
providers: [
{
provide: ErrorHandler,
/* здесь зависит от вашей фантазии, воспользоваться классом или методом */
useValue: customErrorHandler(),
useClass: CustomErrorHandler,
},
// дополнительно можно встроить обработчики для разных провайдеров по типу HttpService
],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment