From 0dbba32d0e2e43404ffeba2d20d0d6121512e97e Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Mon, 3 Jun 2019 11:05:33 +0200 Subject: [PATCH] Client error handling --- client/src/app/site/base/base-view.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/client/src/app/site/base/base-view.ts b/client/src/app/site/base/base-view.ts index 496ba6b38..129c1d872 100644 --- a/client/src/app/site/base/base-view.ts +++ b/client/src/app/site/base/base-view.ts @@ -58,10 +58,15 @@ export abstract class BaseViewComponent extends BaseComponent implements OnDestr * Opens an error snack bar with the given error message. * This is implemented as an arrow function to capture the called `this`. You can use this function * as callback (`.then(..., this.raiseError)`) instead of doing `this.raiseError.bind(this)`. - * @param message The message to show. + * + * @param message The message to show or an "real" error, which will be passed to the console. */ - protected raiseError = (message: string): void => { - this.messageSnackBar = this.matSnackBar.open(message, this.translate.instant('OK'), { + protected raiseError = (message: string | Error): void => { + if (message instanceof Error) { + console.error(message); + message = this.translate.instant('A client error occured. Please contact your system administrator.'); + } + this.messageSnackBar = this.matSnackBar.open(message as string, this.translate.instant('OK'), { duration: 0 }); };