diff --git a/src/lib/backend/errors.test.ts b/src/lib/backend/errors.test.ts index 0dea3609..c0144908 100644 --- a/src/lib/backend/errors.test.ts +++ b/src/lib/backend/errors.test.ts @@ -12,7 +12,6 @@ import { InternalError, BackendError, normalizeBackendError, - HTTP_ERROR_CODES, } from './errors'; import { ERROR_CODE_REGISTRY } from './errorCodes'; @@ -123,24 +122,17 @@ describe('Other error classes — no retryAfter', () => { }); }); -describe('HTTP_ERROR_CODES', () => { - it('should include 429 with TOO_MANY_REQUESTS', () => { - expect(HTTP_ERROR_CODES[429]).toBe('TOO_MANY_REQUESTS'); - }); +describe('HTTP_ERROR_CODES removal', () => { + it('no longer exports the deprecated HTTP status map', async () => { + const errorsModule = await import('./errors'); - it('should include 503 with SERVICE_UNAVAILABLE', () => { - expect(HTTP_ERROR_CODES[503]).toBe('SERVICE_UNAVAILABLE'); + expect('HTTP_ERROR_CODES' in errorsModule).toBe(false); }); - it('should include all standard error codes', () => { - expect(HTTP_ERROR_CODES[400]).toBe('BAD_REQUEST'); - expect(HTTP_ERROR_CODES[401]).toBe('UNAUTHORIZED'); - expect(HTTP_ERROR_CODES[403]).toBe('FORBIDDEN'); - expect(HTTP_ERROR_CODES[404]).toBe('NOT_FOUND'); - expect(HTTP_ERROR_CODES[409]).toBe('CONFLICT'); - expect(HTTP_ERROR_CODES[500]).toBe('INTERNAL_ERROR'); - expect(HTTP_ERROR_CODES[502]).toBe('BAD_GATEWAY'); - expect(HTTP_ERROR_CODES[504]).toBe('GATEWAY_TIMEOUT'); + it('keeps ERROR_CODE_REGISTRY as the single error-code source of truth', async () => { + const errorsModule = await import('./errors'); + + expect(errorsModule.ERROR_CODE_REGISTRY).toBe(ERROR_CODE_REGISTRY); }); }); diff --git a/src/lib/backend/errors.ts b/src/lib/backend/errors.ts index 62a617b9..1d1b2798 100644 --- a/src/lib/backend/errors.ts +++ b/src/lib/backend/errors.ts @@ -122,31 +122,6 @@ export class InternalError extends ApiError { } } -// ─── HTTP status → error code mapping ─────────────────────────────────────── - -/** - * Map of HTTP status codes to their canonical error code strings. - * - * @deprecated Use ERROR_CODE_REGISTRY from errorCodes.ts for detailed error - * documentation including meaning, client handling, and retriable status. - * - * @see ERROR_CODE_REGISTRY - */ -export const HTTP_ERROR_CODES: Record = { - 400: 'BAD_REQUEST', - 401: 'UNAUTHORIZED', - 403: 'FORBIDDEN', - 404: 'NOT_FOUND', - 409: 'CONFLICT', - 413: 'PAYLOAD_TOO_LARGE', - 422: 'UNPROCESSABLE_ENTITY', - 429: 'TOO_MANY_REQUESTS', - 500: 'INTERNAL_ERROR', - 502: 'BAD_GATEWAY', - 503: 'SERVICE_UNAVAILABLE', - 504: 'GATEWAY_TIMEOUT', -}; - // ─── Legacy BackendError (kept for backward compatibility) ──────────────────── export type BackendErrorCode =