From 4ed344b82e5b4f154d6d24bc1ae1f0141370d384 Mon Sep 17 00:00:00 2001 From: FlayInAHook Date: Thu, 3 Dec 2020 23:12:31 +0100 Subject: [PATCH] WIP multi error catching --- src/app/helper/snackbar-dialog.html | 5 +++-- src/app/helper/snackbar-ref.component.ts | 7 +++++-- src/app/helper/token.interceptor.ts | 2 +- src/app/services/snackbar.service.ts | 5 +++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/app/helper/snackbar-dialog.html b/src/app/helper/snackbar-dialog.html index 1bddf5b..d5f7702 100644 --- a/src/app/helper/snackbar-dialog.html +++ b/src/app/helper/snackbar-dialog.html @@ -1,5 +1,6 @@ -

Dialog with elements

-
This dialog showcases the title, close, content and actions elements.
+

Erweiterte Fehlerinfos

+ +
{{error["message"]}}
diff --git a/src/app/helper/snackbar-ref.component.ts b/src/app/helper/snackbar-ref.component.ts index 2d4ff33..d4c777a 100644 --- a/src/app/helper/snackbar-ref.component.ts +++ b/src/app/helper/snackbar-ref.component.ts @@ -23,7 +23,8 @@ export class ErrorSnackbarComponent { public actionAndDismiss(){ console.log("test"); - this.dialog.open(SnackbarDialog); + let dialogRef = this.dialog.open(SnackbarDialog); + dialogRef.componentInstance.errorMessages = this.data.errorMessages; this.snackBarRef.dismiss() } } @@ -32,4 +33,6 @@ export class ErrorSnackbarComponent { selector: 'app-snackbar-dialog', templateUrl: 'snackbar-dialog.html', }) - export class SnackbarDialog {} \ No newline at end of file + export class SnackbarDialog { + errorMessages : Object[]; + } \ No newline at end of file diff --git a/src/app/helper/token.interceptor.ts b/src/app/helper/token.interceptor.ts index a60e2c9..1778d6e 100644 --- a/src/app/helper/token.interceptor.ts +++ b/src/app/helper/token.interceptor.ts @@ -29,7 +29,7 @@ export class TokenInterceptor implements HttpInterceptor { errorMessage = `Error: ${error.error.message}`; } else { //server error - console.log("Error: " + JSON.stringify(error)); + //console.log("Error: " + JSON.stringify(error)); if (error.status === 400){ switch (error.error.message) { case "Invalid refresh token!": diff --git a/src/app/services/snackbar.service.ts b/src/app/services/snackbar.service.ts index 05f6f07..a4bdbc4 100644 --- a/src/app/services/snackbar.service.ts +++ b/src/app/services/snackbar.service.ts @@ -10,9 +10,9 @@ export class SnackBarService { constructor(private snackBar : MatSnackBar) { } - openSnackBar(message: string, action: string = "", error: boolean = false, errorMessageArray: Object[] = undefined) { + openSnackBar(message: string, action: string = "", error: boolean = false, errorMessages: Object[] = undefined) { if (error){ - if (errorMessageArray === undefined){ + if (errorMessages === undefined){ this.snackBar.open(message, action, { duration: 5000, panelClass: ['mat-toolbar', 'mat-warn', 'simple-snack-bar'] @@ -22,6 +22,7 @@ export class SnackBarService { data: { "message" : message, "action" : action, + "errorMessages" : errorMessages }, panelClass: ['mat-toolbar', 'mat-warn', 'simple-snack-bar'], duration: 5000