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

Function getApiErrorCandidates

common/src/util/error.ts:261–287  ·  view source on GitHub ↗
(
  error: unknown,
  seen = new Set<object>(),
)

Source from the content-addressed store, hash-verified

259}
260
261function getApiErrorCandidates(
262 error: unknown,
263 seen = new Set<object>(),
264): unknown[] {
265 if (!error || typeof error !== 'object') return [error]
266 if (seen.has(error)) return []
267 seen.add(error)
268
269 const candidates: unknown[] = [error]
270 const errorWithNested = error as {
271 lastError?: unknown
272 errors?: unknown[]
273 cause?: unknown
274 }
275
276 candidates.push(...getApiErrorCandidates(errorWithNested.lastError, seen))
277
278 if (Array.isArray(errorWithNested.errors)) {
279 for (const nestedError of [...errorWithNested.errors].reverse()) {
280 candidates.push(...getApiErrorCandidates(nestedError, seen))
281 }
282 }
283
284 candidates.push(...getApiErrorCandidates(errorWithNested.cause, seen))
285
286 return candidates
287}
288
289function getApiErrorStatusCode(error: unknown): number | undefined {
290 if (!error || typeof error !== 'object') return undefined

Callers 1

extractApiErrorDetailsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected