import { CallRequestDTO } from '../CallRequestDTO' import { CallResponseDTO } from '../CallResponseDTO' export class InterceptorError extends Error { readonly type: 'request' | 'response' readonly originalError: Error readonly request: CallRequestDTO readonly response?: CallResponseDTO readonly interceptorIndex: number constructor(opts: { type: 'request' | 'response' originalError: Error request: CallRequestDTO response?: CallResponseDTO interceptorIndex: number }) { const { type, originalError, request, response, interceptorIndex } = opts super( `${type.charAt(0).toUpperCase() + type.slice(1)} interceptor #${interceptorIndex + 1} failed: ${originalError.message}`, ) this.name = 'InterceptorError' this.type = type this.originalError = originalError this.request = request this.response = response this.interceptorIndex = interceptorIndex // Maintain stack trace if (Error.captureStackTrace) { Error.captureStackTrace(this, InterceptorError) } } }