MCPcopy Create free account
hub / github.com/TestSprite/testsprite-cli / codeFromHttpStatus

Function codeFromHttpStatus

src/lib/errors.ts:301–326  ·  view source on GitHub ↗

* Every facade-emitted HTTP status maps to a * known error code. When the envelope is missing or its `code` field is * unrecognized (proxy returned an empty body, content was mangled), we fall * back to the status-derived code so the retry budget and exit code match * what the contract promises.

(status: number | undefined)

Source from the content-addressed store, hash-verified

299 * what the contract promises.
300 */
301function codeFromHttpStatus(status: number | undefined): ErrorCode {
302 switch (status) {
303 case 400:
304 return 'VALIDATION_ERROR';
305 case 401:
306 return 'AUTH_INVALID';
307 case 403:
308 return 'AUTH_FORBIDDEN';
309 case 404:
310 return 'NOT_FOUND';
311 case 409:
312 return 'CONFLICT';
313 case 412:
314 return 'PRECONDITION_FAILED';
315 case 413:
316 return 'PAYLOAD_TOO_LARGE';
317 case 429:
318 return 'RATE_LIMITED';
319 case 501:
320 return 'UNSUPPORTED';
321 case 503:
322 return 'UNAVAILABLE';
323 default:
324 return 'INTERNAL';
325 }
326}
327
328/**
329 * Detect the "insufficient credits" sub-case of a RATE_LIMITED (429) envelope.

Callers 1

parseEnvelopeBodyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected