* Pull the human-readable message out of harness-api's error envelope. Falls * back to the status line so a proxy/edge error page (which is not JSON) still * produces something actionable rather than "undefined".
(response)
| 134 | * produces something actionable rather than "undefined". |
| 135 | */ |
| 136 | async function readErrorMessage(response) { |
| 137 | try { |
| 138 | const body = await response.json(); |
| 139 | const message = body?.error?.message; |
| 140 | if (typeof message === "string" && message) return message; |
| 141 | } catch { |
| 142 | // Non-JSON body (edge HTML, empty 502) — fall through to the status line. |
| 143 | } |
| 144 | return `${response.status} ${response.statusText}`.trim(); |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * @param {object} options |