MCPcopy Create free account
hub / github.com/openstatusHQ/openstatus / codeToStatus

Function codeToStatus

packages/error/src/utils.ts:30–53  ·  view source on GitHub ↗
(code: ErrorCode)

Source from the content-addressed store, hash-verified

28}
29
30export function codeToStatus(code: ErrorCode) {
31 switch (code) {
32 case "BAD_REQUEST":
33 return 400;
34 case "UNAUTHORIZED":
35 return 401;
36 case "PAYMENT_REQUIRED":
37 return 402;
38 case "FORBIDDEN":
39 return 403;
40 case "NOT_FOUND":
41 return 404;
42 case "METHOD_NOT_ALLOWED":
43 return 405;
44 case "CONFLICT":
45 return 409;
46 case "UNPROCESSABLE_ENTITY":
47 return 422;
48 case "INTERNAL_SERVER_ERROR":
49 return 500;
50 default:
51 return 500;
52 }
53}
54
55// Props to cal.com: https://github.com/calcom/cal.com/blob/5d325495a9c30c5a9d89fc2adfa620b8fde9346e/packages/lib/server/getServerErrorFromUnknown.ts#L17
56export function parseZodErrorIssues(issues: ZodIssue[]): string {

Callers 1

constructorMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected