(res)
| 4385 | ----------------------------- */ |
| 4386 | // Parse JSON if possible; throw on non-2xx with useful message & status |
| 4387 | async function safeJson(res) { |
| 4388 | const text = await res.text(); |
| 4389 | let body = null; |
| 4390 | try { body = text ? JSON.parse(text) : null; } catch (e) { /* ignore */ } |
| 4391 | |
| 4392 | if (!res.ok) { |
| 4393 | const msg = |
| 4394 | (body && (body.error || body.message)) || |
| 4395 | (text && text.trim()) || |
| 4396 | `HTTP ${res.status}`; |
| 4397 | const err = new Error(msg); |
| 4398 | err.status = res.status; |
| 4399 | throw err; |
| 4400 | } |
| 4401 | return body ?? {}; |
| 4402 | } |
| 4403 | |
| 4404 | function normalizeFolderPath(folder) { |
| 4405 | if (!folder) return ""; |
no outgoing calls
no test coverage detected