MCPcopy Create free account
hub / github.com/CommandCodeAI/BaseAI / codeToStatus

Function codeToStatus

packages/baseai/src/dev/hono/errors.ts:88–110  ·  view source on GitHub ↗
(code: ErrorCodesType)

Source from the content-addressed store, hash-verified

86export type ErrorSchemaType = z.infer<typeof ErrorSchema>;
87
88function codeToStatus(code: ErrorCodesType): StatusCode {
89 switch (code) {
90 case 'BAD_REQUEST':
91 return 400;
92 case 'UNAUTHORIZED':
93 return 401;
94 case 'FORBIDDEN':
95 case 'DISABLED':
96 case 'INSUFFICIENT_PERMISSIONS':
97 case 'USAGE_EXCEEDED':
98 return 403;
99 case 'NOT_FOUND':
100 return 404;
101 case 'CONFLICT':
102 return 409;
103 case 'PRECONDITION_FAILED':
104 return 412;
105 case 'RATE_LIMITED':
106 return 429;
107 case 'INTERNAL_SERVER_ERROR':
108 return 500;
109 }
110}
111
112export class ApiError extends HTTPException {
113 public readonly code: ErrorCodesType;

Callers 3

constructorMethod · 0.85
constructorMethod · 0.85
errorResponseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected