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