(body: string)
| 84 | } |
| 85 | |
| 86 | function extractUpstreamMessage(body: string): string { |
| 87 | try { |
| 88 | const parsed = JSON.parse(body); |
| 89 | const extracted = |
| 90 | parsed?.details?.error?.message || |
| 91 | parsed?.error?.message || |
| 92 | parsed?.message || |
| 93 | (typeof parsed?.error === "string" ? parsed.error : null); |
| 94 | if (typeof extracted === "string" && extracted) return extracted; |
| 95 | } catch { |
| 96 | // Not JSON — fall through to raw body |
| 97 | } |
| 98 | return body; |
| 99 | } |
| 100 | |
| 101 | const GenericErrorDetailsSchema = z |
| 102 | .object({ |
no test coverage detected