From 1cd8a973ad34d073475bf677819e751bd2450339 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 28 Sep 2021 18:29:44 -0400 Subject: [PATCH] fix(notifications): handle Error type messages (backport #305) (#306) * fix(notifications): handle Error type messages (#305) (cherry picked from commit 632574163ffe5b5837221fdd4f57e7b5eb6f206b) # Conflicts: # src/app/Notifications/Notifications.tsx * Resolve conflict Co-authored-by: Andrew Azores --- src/app/Notifications/Notifications.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/Notifications/Notifications.tsx b/src/app/Notifications/Notifications.tsx index 4cb4f2fe9..b6d63e967 100644 --- a/src/app/Notifications/Notifications.tsx +++ b/src/app/Notifications/Notifications.tsx @@ -45,7 +45,7 @@ export interface Notification { read?: boolean; key?: string; title: string; - message?: string; + message?: string | Error; variant: AlertVariant; timestamp?: number; } @@ -61,6 +61,11 @@ export class Notifications { } notification.read = false; notification.timestamp = +Date.now(); + if (notification.message instanceof Error) { + notification.message = JSON.stringify(notification.message, Object.getOwnPropertyNames(notification.message)); + } else if (typeof notification.message !== 'string') { + notification.message = JSON.stringify(notification.message); + } this._notifications.unshift(notification); this._notifications$.next(this._notifications); }