Skip to content

Commit

Permalink
notifications: Log errors in the Browser console, once
Browse files Browse the repository at this point in the history
  • Loading branch information
mvollmer committed Dec 9, 2020
1 parent 093bdab commit 4d5ab11
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Notification.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,19 @@ import cockpit from 'cockpit';

const _ = cockpit.gettext;

let last_error = "";

function log_error_if_changed(error) {
// Put the error in the browser log, for easier debugging and
// matching of known issues in the integration tests.
if (error != last_error) {
last_error = error;
console.error(error);
}
}

export const ErrorNotification = ({ errorMessage, errorDetail, onDismiss }) => {
log_error_if_changed(errorMessage + (errorDetail ? ": " + errorDetail : ""));
return (
<Alert isInline variant='danger' title={errorMessage}
actionClose={onDismiss ? <AlertActionCloseButton onClose={onDismiss} /> : null}>
Expand Down

0 comments on commit 4d5ab11

Please sign in to comment.