ErrorMatcher.utils.ts11 lines · main
1import { ERROR_MAPPINGS, type ErrorMapping } from './error-mappings'
2import { ResponseError } from '@/types/base'
3
4export 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}