MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / getErrorStatusCode

Function getErrorStatusCode

sdk/src/error-utils.ts:79–97  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

77 * Checks both 'statusCode' (our convention) and 'status' (AI SDK's APICallError convention).
78 */
79export function getErrorStatusCode(error: unknown): number | undefined {
80 if (error && typeof error === 'object') {
81 // Check 'statusCode' first (our convention)
82 if ('statusCode' in error) {
83 const statusCode = (error as { statusCode: unknown }).statusCode
84 if (typeof statusCode === 'number') {
85 return statusCode
86 }
87 }
88 // Check 'status' (AI SDK's APICallError uses this)
89 if ('status' in error) {
90 const status = (error as { status: unknown }).status
91 if (typeof status === 'number') {
92 return status
93 }
94 }
95 }
96 return undefined
97}
98
99/**
100 * Sanitizes error messages for display

Callers 9

AppFunction · 0.90
formatErrorForDisplayFunction · 0.90
isAuthenticationErrorFunction · 0.90
validateApiKeyFunction · 0.90
useAuthQueryFunction · 0.90
runOnceFunction · 0.90
isOAuthRateLimitErrorFunction · 0.90
isOAuthAuthErrorFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected