MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / getStatusCode

Function getStatusCode

packages/kosong/src/errors.ts:266–282  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

264}
265
266function getStatusCode(error: unknown): number | undefined {
267 if (typeof error !== 'object' || error === null) return undefined;
268
269 const record = error as Record<string, unknown>;
270 const statusCode = record['statusCode'];
271 if (typeof statusCode === 'number') return statusCode;
272 const status = record['status'];
273 if (typeof status === 'number') return status;
274
275 const response = record['response'];
276 if (typeof response !== 'object' || response === null) return undefined;
277 const responseRecord = response as Record<string, unknown>;
278 const responseStatusCode = responseRecord['statusCode'];
279 if (typeof responseStatusCode === 'number') return responseStatusCode;
280 const responseStatus = responseRecord['status'];
281 return typeof responseStatus === 'number' ? responseStatus : undefined;
282}
283
284function errorMessage(error: unknown): string {
285 return error instanceof Error ? error.message : String(error);

Callers 1

isProviderRateLimitErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected