ErrorMatcher.utils.ts 410 B

1234567891011
  1. import { ERROR_MAPPINGS, type ErrorMapping } from './error-mappings'
  2. import { ResponseError } from '@/types/base'
  3. export function getMappingForError(error: unknown): ErrorMapping | null {
  4. const isResponseError = error instanceof ResponseError
  5. if (!isResponseError) return null
  6. for (const [ErrorClass, mapping] of ERROR_MAPPINGS) {
  7. if (error instanceof ErrorClass) return mapping
  8. }
  9. return null
  10. }