Our current situation is as described, we have a huge angular application where a lot off API calls are fired in various components with error-handling so error will be displayed to the user with a toast-message.
In our HttpService
we are doing something like this:
lorem.pipe(
...
catchError(this.formatError)
);
...
formatError(error) {
return throwError(error.error);
}
error.error
contains a JSON error-message like { success: false, code: 'XY' }
In our components we are using the success code to display an appropriate error message.
Now the problem:
We are using Sentry.io to capture client exceptions using the ErrorHandler
functionality of angular, but it seems like the handleError
function excepts a proper Object
of type Event
and therefore we are getting a lot of falsey error message transmitted.
My question is, is there any possibility to map
the error result after it has been thrown, so that the handleError
function of the ErrorHandler
receives a valid Event
but the error section in the subscribe
of the observable inside the components will still get the JSON-Object
as error, so we don't have to rewrite every error-handling and still get an Event
for the ErrorHandler
?