Skip to content

setErrorHandler

setErrorHandler(handler?): void

Defined in: aberdeen.ts:3254

Sets a custom error handler function for errors that occur asynchronously within reactive scopes (e.g., during updates triggered by proxy changes in derive or A render functions).

The default handler logs the error to console.error and adds a simple ‘Error’ message div to the DOM at the location where the error occurred (if possible).

Your handler can provide custom logging, UI feedback, or suppress the default error message.

(error) => boolean

A function that accepts the Error object.

  • Return false to prevent adding an error message to the DOM.
  • Return true or undefined (or throw) to allow the error messages to be added to the DOM.

void

Custom Logging and Suppressing Default Message

A.setErrorHandler(error => {
console.warn('Aberdeen render error:', error.message);
// Log to error reporting service
// myErrorReporter.log(error);
try {
// Attempt to show a custom message in the UI
A('div#Oops, something went wrong!', errorClass);
} catch (e) {
// Ignore errors during error handling itself
}
return false; // Suppress default console log and DOM error message
});
// Styling for our custom error message
const errorClass = A.insertCss('background-color:#e31f00 display:inline-block color:white r:3px padding: 2px 4px;');
// Cause an error within a render scope.
A('div.box', () => {
// Will cause our error handler to insert an error message within the box
noSuchFunction();
})