I have situation where I call an API to save data both manually and automatically,
- In case of manual save I want to show the error if save fails, and I achieved this using angular global error handler.
- In case of automatic save I want to ignore the error, but as I have global error handler its catching the error and showing it to user as per the implementation.
I am trying to find a way to manage this error handling based on some condition.
following are some code snippets for better understating of problem
Global error handler
export class GlobalErrorHandlerService implements ErrorHandler {
constructor(private notification2Service: NotificationService,
private loggingService: LoggingApiService) {
}
handleError(error: any): void {
this.notification2Service.notify(error.message);
this.loggingService.logError(error);
}
}
Save method
post(path: string, body: Object = {}, skipSpinner = 'false'): Observable<any> {
let fullPath = this.getBaseApiUrl(path);
return this.http.post(fullPath,body,{
headers: {'skip-spinner':skipSpinner}
});
}
what I want is global error handler should ignore errors in this call if "skipSpinner" is 'true'