Refactor error interceptor.
This commit is contained in:
@@ -27,19 +27,12 @@ export class ErrorInterceptor implements HttpInterceptor {
|
||||
if (err.error instanceof ErrorEvent) {
|
||||
// A client-side or network error occurred. Handle it accordingly.
|
||||
errorMessage = `An error occurred: ${err.error.message}`;
|
||||
this.loggingService.sendErrorLevelMessage(errorMessage, this, {error: err});
|
||||
} else {
|
||||
// The backend returned an unsuccessful response code.
|
||||
// The response body may contain clues as to what went wrong.
|
||||
errorMessage = `Backend returned code ${err.status}, body was: ${JSON.stringify(err.error)}`;
|
||||
this.loggingService.sendErrorLevelMessage(errorMessage, this, {error: err});
|
||||
}
|
||||
// if (isDevMode()) {
|
||||
// this.errorDialogService.openDialog({
|
||||
// message: errorMessage || err.error.message || err.statusText || 'Unknown Error',
|
||||
// status: err.status || 0
|
||||
// });
|
||||
// }
|
||||
this.loggingService.sendErrorLevelMessage(errorMessage, this, {error: err});
|
||||
switch (err.status) {
|
||||
case 401: // unauthorized
|
||||
this.router.navigateByUrl('/auth').then();
|
||||
|
||||
Reference in New Issue
Block a user