MCPcopy Create free account
hub / github.com/rmyndharis/OpenWA / classifyApiError

Function classifyApiError

sdk/javascript/src/errors.ts:95–112  ·  view source on GitHub ↗
(status: number, message: string, body: unknown, errorKind?: string)

Source from the content-addressed store, hash-verified

93 * Falls back to the generic {@link OpenWAApiError} for unmapped statuses.
94 */
95export function classifyApiError(status: number, message: string, body: unknown, errorKind?: string): OpenWAApiError {
96 switch (status) {
97 case 401:
98 return new OpenWAAuthError(message, status, body, errorKind);
99 case 403:
100 return new OpenWAForbiddenError(message, status, body, errorKind);
101 case 404:
102 return new OpenWANotFoundError(message, status, body, errorKind);
103 case 409:
104 return new OpenWAConflictError(message, status, body, errorKind);
105 case 429:
106 return new OpenWARateLimitError(message, status, body, errorKind);
107 case 501:
108 return new OpenWANotImplementedError(message, status, body, errorKind);
109 default:
110 return new OpenWAApiError(message, status, body, errorKind);
111 }
112}
113
114/** Narrow the NestJS error envelope shape: `{ statusCode, message, error }`. */
115interface NestErrorEnvelope {

Callers 1

requestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected