Skip to content

Commit

Permalink
fix(notifications): handle Error type messages (backport #305) (#306)
Browse files Browse the repository at this point in the history
* fix(notifications): handle Error type messages (#305)

(cherry picked from commit 6325741)

# Conflicts:
#	src/app/Notifications/Notifications.tsx

* Resolve conflict

Co-authored-by: Andrew Azores <aazores@redhat.com>
  • Loading branch information
mergify[bot] and andrewazores authored Sep 28, 2021
1 parent 34a6c64 commit 1cd8a97
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/app/Notifications/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface Notification {
read?: boolean;
key?: string;
title: string;
message?: string;
message?: string | Error;
variant: AlertVariant;
timestamp?: number;
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 1cd8a97

Please sign in to comment.