mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-06-29 14:31:11 +02:00
Better error rendering
This commit is contained in:
+2
-2
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -13,7 +13,7 @@
|
||||
<link rel="shortcut icon" href="/favicon.ico" />
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
||||
<link rel="manifest" href="/site.webmanifest" />
|
||||
<script type="module" crossorigin src="/assets/index-Z2aWr4hK.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-Djay-rUY.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-BpFnqQF8.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
+12
-2
@@ -26,8 +26,18 @@ async function fetchJson<T>(url: string, options?: RequestInit): Promise<T> {
|
||||
},
|
||||
});
|
||||
if (!res.ok) {
|
||||
const error = await res.text();
|
||||
throw new Error(error || res.statusText);
|
||||
const errorText = await res.text();
|
||||
// FastAPI returns errors as {"detail": "message"}, extract the message
|
||||
let errorMessage = errorText || res.statusText;
|
||||
try {
|
||||
const errorJson = JSON.parse(errorText);
|
||||
if (errorJson.detail) {
|
||||
errorMessage = errorJson.detail;
|
||||
}
|
||||
} catch {
|
||||
// Not JSON, use raw text
|
||||
}
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user