MCPcopy Create free account
hub / github.com/OpenHands/OpenHands / readErrorMessage

Function readErrorMessage

scripts/mars-api.mjs:136–145  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

134 * produces something actionable rather than "undefined".
135 */
136async 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

Callers 1

requestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected