Function type for transforming errors

Error transforms allow you to customize error handling globally. They are executed in registration order for all errors.

Returns

The transformed error (can be the same or a new error)

Example

const errorTransform: ErrorTransform = async (error, ctx) => {
const enhancedError = new Error(`[${ctx.request.url}] ${error.message}`);
enhancedError.stack = error.stack;
return enhancedError;
};
interface ErrorTransform ((error, ctx) => Error | Promise<Error>)
  • Parameters

    Returns Error | Promise<Error>