MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / resolveFinalStatus

Function resolveFinalStatus

apps/api/src/middleware/error-handler.ts:86–102  ·  view source on GitHub ↗
(code: string, error: unknown)

Source from the content-addressed store, hash-verified

84 * `statusCode`, and Elysia-thrown codes map below.
85 */
86const resolveFinalStatus = (code: string, error: unknown): number => {
87 if (error instanceof ApiError) {
88 return error.statusCode;
89 }
90
91 switch (code) {
92 case ElysiaErrorCodes.NOT_FOUND:
93 return 404;
94 case ElysiaErrorCodes.VALIDATION:
95 case ElysiaErrorCodes.PARSE:
96 return 400;
97 case ElysiaErrorCodes.INVALID_COOKIE_SIGNATURE:
98 return 401;
99 default:
100 return 500;
101 }
102};
103
104export const errorHandler = ({
105 code,

Callers 1

errorHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected