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