MCPcopy Create free account
hub / github.com/Noumena-Network/code / getErrorCode

Function getErrorCode

src/services/api/openAICompatInferenceClient.ts:113–131  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

111}
112
113function getErrorCode(error: unknown): string | undefined {
114 let current = error
115 for (let depth = 0; depth < 5; depth += 1) {
116 if (!current || typeof current !== 'object') {
117 return undefined
118 }
119 if (
120 'code' in current &&
121 typeof (current as { code?: unknown }).code === 'string'
122 ) {
123 return (current as { code: string }).code
124 }
125 if (!('cause' in current) || (current as { cause?: unknown }).cause === current) {
126 return undefined
127 }
128 current = (current as { cause?: unknown }).cause
129 }
130 return undefined
131}
132
133function isAbortLike(error: unknown): boolean {
134 return error instanceof Error && error.name === 'AbortError'

Callers 1

constructorMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected