Skip to content

Instantly share code, notes, and snippets.

@trumbitta
Created June 6, 2019 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trumbitta/5f3d0fbc4acfc02bc4bce07ffa25a20e to your computer and use it in GitHub Desktop.
Save trumbitta/5f3d0fbc4acfc02bc4bce07ffa25a20e to your computer and use it in GitHub Desktop.
export class HttpErrorInterceptor implements HttpInterceptor {
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(request).pipe(
tap(
() => {},
error => {
// There may be other events besides the response error.
if (
error instanceof HttpErrorResponse
) {
// do stuff
}
}
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment