@serenity-is/corelib / ErrorHandling / unhandledRejectionHandler
Function: unhandledRejectionHandler()
unhandledRejectionHandler(
err):void
Defined in: src/base/errorhandling.tsx:143
Handler for unhandledrejection events that filters expected service errors and surfaces real bugs during development.
Parameters
err
PromiseRejectionEvent
The PromiseRejectionEvent fired by the browser.
Returns
void
Remarks
- When
err.reason.origin === "serviceCall"(Serenity service layer), the rejection is suppressed viapreventDefault()and, unlesssilentorkind !== "exception", logged to the console. This avoids noisy console errors for handled service failures. - For all other rejections, a notification is shown only when ErrorHandling.isDevelopmentMode returns
true.
Example
window.addEventListener("unhandledrejection", ErrorHandling.unhandledRejectionHandler);