error-mappings.tsx22 lines · main
| 1 | import { ComponentType } from 'react' |
| 2 | |
| 3 | import { ConnectionTimeoutTroubleshooting } from './errorMappings/ConnectionTimeout' |
| 4 | import { ConnectionTimeoutError } from '@/types/api-errors' |
| 5 | import type { ClassifiedError, KnownErrorType } from '@/types/api-errors' |
| 6 | import type { ResponseError } from '@/types/base' |
| 7 | |
| 8 | export interface ErrorMapping { |
| 9 | id: KnownErrorType |
| 10 | Troubleshooting: ComponentType |
| 11 | } |
| 12 | |
| 13 | type ErrorConstructor = new ( |
| 14 | ...args: ConstructorParameters<typeof ResponseError> |
| 15 | ) => ClassifiedError |
| 16 | |
| 17 | export const ERROR_MAPPINGS = new Map<ErrorConstructor, ErrorMapping>([ |
| 18 | [ |
| 19 | ConnectionTimeoutError, |
| 20 | { id: 'connection-timeout', Troubleshooting: ConnectionTimeoutTroubleshooting }, |
| 21 | ], |
| 22 | ]) |