Factory function to create strongly-typed custom error classes.
A string literal type that defines specific error types.
A shape of the additional metadata provided with the error.
Configuration for the custom error.
A class constructor for the custom error.
const PaymentFailedError = createHandleError({ name: 'PaymentFailedError', statusCode: 402, defaultType: 'PAYMENT_FAILED', defaultMessage: 'Payment could not be processed'})throw new PaymentFailedError()throw new PaymentFailedError('Card declined', 'PAYMENT_DECLINED', { retry: false }) Copy
const PaymentFailedError = createHandleError({ name: 'PaymentFailedError', statusCode: 402, defaultType: 'PAYMENT_FAILED', defaultMessage: 'Payment could not be processed'})throw new PaymentFailedError()throw new PaymentFailedError('Card declined', 'PAYMENT_DECLINED', { retry: false })
Factory function to create strongly-typed custom error classes.