Created
June 6, 2019 09:55
-
-
Save trumbitta/5f3d0fbc4acfc02bc4bce07ffa25a20e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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