MCPcopy Create free account
hub / github.com/anus-dev/ANUS / getErrorStatus

Function getErrorStatus

packages/core/src/utils/retry.ts:224–244  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

222 * @returns The HTTP status code, or undefined if not found.
223 */
224export function getErrorStatus(error: unknown): number | undefined {
225 if (typeof error === 'object' && error !== null) {
226 if ('status' in error && typeof error.status === 'number') {
227 return error.status;
228 }
229 // Check for error.response.status (common in axios errors)
230 if (
231 'response' in error &&
232 typeof (error as { response?: unknown }).response === 'object' &&
233 (error as { response?: unknown }).response !== null
234 ) {
235 const response = (
236 error as { response: { status?: unknown; headers?: unknown } }
237 ).response;
238 if ('status' in response && typeof response.status === 'number') {
239 return response.status;
240 }
241 }
242 }
243 return undefined;
244}
245
246/**
247 * Extracts the Retry-After delay from an error object's headers.

Callers 3

retryWithBackoffFunction · 0.85
promptMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected