(response: Response)
| 124 | } |
| 125 | |
| 126 | async function readResponseBody(response: Response): Promise<{ parsed: unknown; raw?: string }> { |
| 127 | const text = await response.text() |
| 128 | if (!text) return { parsed: undefined } |
| 129 | |
| 130 | try { |
| 131 | return { parsed: JSON.parse(text) as unknown, raw: text } |
| 132 | } catch { |
| 133 | return { parsed: text, raw: text } |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | function messageFromErrorBody(body: unknown, fallback: string): string { |
| 138 | if (body && typeof body === 'object') { |
no test coverage detected