Interface ResponseErrorInterceptor

Defines the interceptor for a Response error. This allows you to intercept a response error before exiting the whole process. You can either rethrow an error, and resolve with a different response.

You must return either:

  1. An error (throw error or Promise.reject(error))
  2. Data (directly, or via a Promise)

Reports error to tracking service:

const reportErrorToTrackingService: ResponseErrorInterceptor = async ({
request,
error,
}: {
request: Request
error: unknown
}) => {
await sendErrorToErrorService(request, error)
throw error
}