error-mappings.tsx 702 B

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