MCPcopy Index your code
hub / github.com/emdash-cms/emdash / apiError

Function apiError

packages/core/src/api/error.ts:31–43  ·  view source on GitHub ↗
(
	code: string,
	message: string,
	status: number,
	details?: Record<string, unknown>,
)

Source from the content-addressed store, hash-verified

29 * Use this for all error responses in API routes.
30 */
31export function apiError(
32 code: string,
33 message: string,
34 status: number,
35 details?: Record<string, unknown>,
36): Response {
37 const error: { code: string; message: string; details?: Record<string, unknown> } = {
38 code,
39 message,
40 };
41 if (details !== undefined) error.details = details;
42 return Response.json({ error }, { status, headers: API_CACHE_HEADERS });
43}
44
45/**
46 * Create a standardized success response.

Callers 15

POSTFunction · 0.85
POSTFunction · 0.85
rateLimitResponseFunction · 0.85
handlePasskeyAuthFunction · 0.85
GETFunction · 0.85
POSTFunction · 0.85
POSTFunction · 0.85
GETFunction · 0.85
GETFunction · 0.85
POSTFunction · 0.85
GETFunction · 0.85
GETFunction · 0.85

Calls 1

jsonMethod · 0.65

Tested by

no test coverage detected