Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions src/lib/backend/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
InternalError,
BackendError,
normalizeBackendError,
HTTP_ERROR_CODES,
} from './errors';
import { ERROR_CODE_REGISTRY } from './errorCodes';

Expand Down Expand Up @@ -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);
});
});

Expand Down
25 changes: 0 additions & 25 deletions src/lib/backend/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number, string> = {
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 =
Expand Down