Refactor error interceptor.

This commit is contained in:
Spencer Ofwiti
2021-03-22 16:56:34 +03:00
parent aceccedf5e
commit 4bfce9eff7
2 changed files with 2 additions and 9 deletions

View File

@@ -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();