MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / fail

Function fail

src/ui-server/api/respond.ts:69–89  ·  view source on GitHub ↗
(res: ServerResponse, err: unknown, method: string)

Source from the content-addressed store, hash-verified

67
68/** Send a failure. Anything that is not an {@link ApiError} becomes a 500. */
69export function fail(res: ServerResponse, err: unknown, method: string): true {
70 if (err instanceof ApiError) {
71 const body: { error: string; code: ApiErrorCode; hint?: string } = {
72 error: err.message,
73 code: err.code,
74 };
75 if (err.hint) body.hint = err.hint;
76 sendJson(res, STATUS[err.code], body, method);
77 return true;
78 }
79 sendJson(
80 res,
81 500,
82 {
83 error: err instanceof Error ? err.message : String(err),
84 code: 'internal' satisfies ApiErrorCode,
85 },
86 method
87 );
88 return true;
89}
90
91// =============================================================================
92// Request bodies

Callers 1

handlerFunction · 0.90

Calls 1

sendJsonFunction · 0.90

Tested by

no test coverage detected