I have a web service returning custom errors inside a 200
Response, in a classic errors
object.
This breaks my workflow and patterns, where I usually intercept proper HTTP error status codes and go on with handling the various error cases from there.
I need to transform these custom errors into proper HttpErrorResponse
errors via an interceptor, so that I can then intercept those now-proper errors and continue with my application per usual best practices.
interceptors/custom-error.interceptor.ts
So that when in the near future I'll be working on several other applications that use the same unmodifiable web service, I can just drop the CustomErrorInterceptor
in and call it a day.
And here's the answer a buddy of mine just found:
throw new HttpErrorResponse({ error: 'bar', status: 403 });
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments