We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e9463a9 commit b96928bCopy full SHA for b96928b
1 file changed
Devices/MystrixSim/WebUI/src/components/FirmwarePage.svelte
@@ -249,7 +249,19 @@
249
async function fetchPackageBytes(url, init = {}) {
250
const response = await fetch(url, init)
251
if (!response.ok) {
252
- throw new Error(`Package request failed: HTTP ${response.status}`)
+ let detail = ''
253
+ try {
254
+ const contentType = response.headers.get('content-type') || ''
255
+ if (contentType.includes('application/json')) {
256
+ const payload = await response.json()
257
+ detail = payload?.error ? `: ${payload.error}` : ''
258
+ } else {
259
+ const text = (await response.text()).trim()
260
+ if (text) detail = `: ${text}`
261
+ }
262
+ } catch {}
263
+
264
+ throw new Error(`Package request failed: HTTP ${response.status}${detail}`)
265
}
266
return await response.arrayBuffer()
267
0 commit comments