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

Function getApiErrorMessage

src/utils/api-error-message.ts:13–31  ·  view source on GitHub ↗
(error: unknown, fallback: string)

Source from the content-addressed store, hash-verified

11 * then `fallback`.
12 */
13export function getApiErrorMessage(error: unknown, fallback: string): string {
14 const body = axios.isAxiosError(error)
15 ? error.response?.data
16 : error instanceof Error && "response" in error
17 ? (error as { response?: unknown }).response
18 : undefined;
19
20 if (body && typeof body === "object") {
21 const { message, detail } = body as {
22 message?: unknown;
23 detail?: unknown;
24 };
25 if (typeof message === "string" && message) return message;
26 if (typeof detail === "string" && detail) return detail;
27 }
28
29 if (error instanceof Error && error.message) return error.message;
30 return fallback;
31}

Callers 5

handleSubmitFunction · 0.90
handleRunNowFunction · 0.90
handleRunNowFunction · 0.90
handleImportConfirmFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected