So I got this code which works great to handle errors, only that I only want to load it when I am not developing, is it possible to set a load condition for useClass
in providers:
providers: [
{
provide: ErrorHandler, // if in dev mode don't load this
useClass: GlobalErrorHandler
}
thanks
Sean
CodePudding user response:
Setup Environments, and export an environment variable in case of dev environment. (empty object in case of production / staging environment)
CodePudding user response:
export function provideGlobalErrorHandler() {
if (Lib.DevMode()) {
return {
provide: ErrorHandler,
useClass: GlobalErrorHandler
};
}
}