Skip to content

Type Alias: ResourcefulErrorMiddlewareEvents ​

ts
type ResourcefulErrorMiddlewareEvents = EventMap<{
  any: [unknown];
  error: [Error];
  exception: [Exception];
  joiValidationError: [ValidationError];
  unknown: [unknown];
  vineValidationError: [VineValidationError];
}>;

Event map defining the types of errors that can be emitted by the ResourcefulErrorMiddleware. Each event type maps to the specific error instance that will be passed to event handlers.

Example ​

typescript
const middleware = new ResourcefulErrorMiddleware({
  onVineValidationError: (error) => logger.warn("Validation failed", error),
  onException: (error) => monitoring.captureException(error),
  onAny: (error) => analytics.trackError(error),
});