DefaultErrorHandlingOptions
Upgather SDK / DefaultErrorHandlingOptions
Interface: DefaultErrorHandlingOptions
Defined in: lib/error/DefaultErrorHandling.ts:12
Configuration options for DefaultErrorHandling.
Properties
errorFormatter()?
optionalerrorFormatter: (response,originalError) =>Error
Defined in: lib/error/DefaultErrorHandling.ts:63
Custom error formatter function.
Parameters
response
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?
optionallogErrors:boolean
Defined in: lib/error/DefaultErrorHandling.ts:22
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?
optionallogger:LoggerInterface
Defined in: lib/error/DefaultErrorHandling.ts:49
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/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,
});