Skip to main content

DefaultErrorHandlingOptions

Upgather SDK


Upgather SDK / DefaultErrorHandlingOptions

Interface: DefaultErrorHandlingOptions

Configuration options for DefaultErrorHandling.

Properties​

errorFormatter()?​

optional errorFormatter: (response, originalError) => Error

Custom error formatter function.

Parameters​

response​

ApiResponse

The API response containing error information

originalError​

Error

The original error that was thrown

Returns​

Error

A formatted error object

Remarks​

Use this to customize how errors are formatted before being thrown. The formatter receives the raw API response and original error, and should return a new Error object with enhanced information.


logErrors?​

optional logErrors: boolean

Whether to log errors to console (default: true).

Deprecated​

Use the logger property instead for more control over logging behavior. This property is maintained for backward compatibility.

Remarks​

When both logErrors and logger are provided, the logger property takes precedence.


logger?​

optional logger: LoggerInterface

Logger instance for error logging. Takes precedence over logErrors flag.

Remarks​

If provided, this logger will be used for all error logging operations. If not provided and logErrors is true, errors will be logged to console directly. If not provided and logErrors is false, no logging will occur.

Example​

Using a custom logger:

import { DefaultErrorHandling, LoggerInterface } from '@upgather/sdk';

const myLogger: LoggerInterface = {
debug: (msg) => console.debug(msg),
info: (msg) => console.info(msg),
warn: (msg) => console.warn(msg),
error: (msg) => console.error(msg),
};

const errorHandler = new DefaultErrorHandling({
logger: myLogger,
});