MCPcopy Create free account
hub / github.com/error311/FileRise / safeJson

Function safeJson

public/js/fileListView.js:4387–4402  ·  view source on GitHub ↗
(res)

Source from the content-addressed store, hash-verified

4385 ----------------------------- */
4386// Parse JSON if possible; throw on non-2xx with useful message & status
4387async 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
4404function normalizeFolderPath(folder) {
4405 if (!folder) return "";

Callers 4

fetchFolderPeekFunction · 0.70
findBestAccessibleFolderFunction · 0.70
fetchFolderCapsFunction · 0.70
loadFileListFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected