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

84const isClientApiError = (error: unknown): boolean =>
85 error instanceof ApiError &&
86 error.statusCode >= 400 &&
87 error.statusCode < 500;
88
89/*
90 * Resolve the final HTTP status BEFORE the log line so observability
91 * surfaces what the client actually saw. Elysia's `set.status` is the
92 * pre-handler default; an `ApiError` overrides it to its own
93 * `statusCode`, and Elysia-thrown codes map below.
94 */
95const resolveFinalStatus = (code: string, error: unknown): number => {
96 if (error instanceof ApiError) {
97 return error.statusCode;
98 }
99
100 switch (code) {
101 case ElysiaErrorCodes.NOT_FOUND:
102 return 404;
103 case ElysiaErrorCodes.VALIDATION:
104 case ElysiaErrorCodes.PARSE:
105 return 400;

Callers 1

errorHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected