Skip to content
This repository was archived by the owner on Oct 31, 2022. It is now read-only.

Error Handler

Maxi edited this page Jul 29, 2019 · 1 revision

Follow this steps to use JamErrorHandler instead of Angular's defalut ErrorHandler.

  1. Provide JamErrorHandler instead of Angular's default ErrorHandler in your AppModule:
import { ErrorHandler } from '@angular/core';
import { JamErrorHandler } from 'ngx-jsonapi-material';
...
providers: [
    ...
    { provide: ErrorHandler, useClass: JamErrorHandler }
    ...
]
...
  1. If you want to automatically show a logout dialog when back end requests authentication, assign a class with a logout method to JamErrorHandler's globalStateService property in your AppModules constructor`:
export class AppModule {
    public constructor(
        public logOutClass: LogOutClass,
        public jamErrorHandler: JamErrorHandler
    ) {
        (errorHandler as JamErrorHandler).globalStateService = logOutClass;
    }
}
Clone this wiki locally