Skip to content

Commit eff88c9

Browse files
committed
feat: display response errors
1 parent 01b2f15 commit eff88c9

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

addons/goboscript/userscript.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@ export default async function ({ addon, console }) {
2828
try {
2929
const beginFilenameWithId = e.shiftKey !== addon.settings.get("beginFilenameWithId");
3030

31-
const data = await (await fetch(`https://faretek-api.vercel.app/api/sb2gs/?id=${projectId}`)).blob();
32-
downloadBlob((beginFilenameWithId ? `${projectId} ` : "") + titleStr + ".zip", data);
31+
const resp = await fetch(`https://faretek-api.vercel.app/api/sb2gs/?id=${projectId}`);
32+
if (resp.status !== 200) {
33+
window.alert(`Failed with code ${resp.status}. Response content: ${await resp.text()}`);
34+
} else {
35+
const data = await resp.blob();
36+
downloadBlob((beginFilenameWithId ? `${projectId} ` : "") + titleStr + ".zip", data);
37+
}
3338
} catch (err) {
3439
window.alert(err);
3540
}

0 commit comments

Comments
 (0)