(bodyText: string)
| 54 | } |
| 55 | |
| 56 | function 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 | |
| 67 | export class ApiError extends Error { |
| 68 | status: number |
no outgoing calls
no test coverage detected