onunhandledrejection
variable
var onunhandledrejection: ((this: Window, ev: PromiseRejectionEvent) => any) | nullEvent handler for unhandled promise rejections.
Triggered when a Promise is rejected and no rejection handler is attached to it.
Example
onunhandledrejection = (event) => {
console.log("Unhandled rejection:", event.reason);
event.preventDefault(); // Prevents the default handling
};
// This will trigger the event handler
Promise.reject(new Error("Example error"));