Skip to content

Commit

Permalink
feat(Demo): Display unhandled rejections in demo (#7638)
Browse files Browse the repository at this point in the history
  • Loading branch information
tykus160 authored Nov 20, 2024
1 parent 93e6921 commit d7e78f6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions demo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ shakaDemo.Main = class {
this.onError_(/** @type {!shaka.util.Error} */ (errorEvent.error));
});

// Display unhandled rejections.
window.addEventListener('unhandledrejection', (event) => {
const rejectionEvent = /** @type {!PromiseRejectionEvent} */(event);
const message =
`Unhandled rejection in promise: ${rejectionEvent.reason}`;
console.error('unhandledrejection', rejectionEvent.reason,
rejectionEvent.promise);
this.handleError_(shaka.util.Error.Severity.CRITICAL, message, '');
});

// Set up event listeners.
document.getElementById('error-display-close-button').addEventListener(
'click', (event) => this.closeError_());
Expand Down

0 comments on commit d7e78f6

Please sign in to comment.