MCPcopy Create free account
hub / github.com/tiann/hapi / parseErrorCode

Function parseErrorCode

web/src/api/client.ts:56–65  ·  view source on GitHub ↗
(bodyText: string)

Source from the content-addressed store, hash-verified

54}
55
56function parseErrorCode(bodyText: string): string | undefined {
57 try {
58 const parsed = JSON.parse(bodyText) as ErrorPayload
59 if (typeof parsed.code === 'string') return parsed.code
60 if (typeof parsed.error === 'string') return parsed.error
61 return undefined
62 } catch {
63 return undefined
64 }
65}
66
67export class ApiError extends Error {
68 status: number

Callers 3

requestMethod · 0.85
authenticateMethod · 0.85
bindMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected