@serenity-is/corelib / ErrorHandling

Namespace: ErrorHandling

Table of contents

Functions

Functions

isDevelopmentMode

isDevelopmentMode(): boolean

Determines if the current environment is development mode. The runtimeErrorHandler (window.onerror) shows error notifications only when this function returns true. The default implementation considers the environment as development mode if the host is localhost, 127.0.0.1, ::1, or a domain name that ends with .local/.localhost.

Returns

boolean

true if the current environment is development mode, false otherwise.

Defined in

src/base/errorhandling.ts:76


runtimeErrorHandler

runtimeErrorHandler(message, filename?, lineno?, colno?, error?): void

Runtime error handler that shows a runtime error as a notification by default only in development mode (@see isDevelopmentMode) This function is assigned as window.onerror handler in ScriptInit.ts for Serenity applications so that developers can notice an error without having to check the browser console.

Parameters

Name Type
message string
filename? string
lineno? number
colno? number
error? Error

Returns

void

Defined in

src/base/errorhandling.ts:40


showServiceError

showServiceError(error, errorInfo?): void

Shows a service error as an alert dialog. If the error is null, has no message or code, it shows "??ERROR??".

Parameters

Name Type
error ServiceError
errorInfo? RequestErrorInfo

Returns

void

Defined in

src/base/errorhandling.ts:12


unhandledRejectionHandler

unhandledRejectionHandler(err): void

Unhandled promise rejection error handler. It's purpose is to ignore logging serviceCall / serviceFetch errors as they have built-in error handling but browser logs it in the console, while Node crashes. Include below code in script-init/errorhandling.ts to enable: window.addEventListener("unhandledrejection", ErrorHandling.unhandledRejectionHandler);

Parameters

Name Type
err PromiseRejectionEvent

Returns

void

Defined in

src/base/errorhandling.ts:92