updated xhr error handling
All checks were successful
Build / Build NPM Project (push) Successful in 42s
Build / Tag Version (push) Successful in 4s

This commit is contained in:
Zakary Timson 2024-06-25 09:58:02 -04:00
parent 1a4e732fd5
commit 7b2d4ba119
2 changed files with 3 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@ztimson/utils", "name": "@ztimson/utils",
"version": "0.12.2", "version": "0.12.3",
"description": "Utility library", "description": "Utility library",
"author": "Zak Timson", "author": "Zak Timson",
"license": "MIT", "license": "MIT",

View File

@ -83,8 +83,8 @@ export class XHR {
const payload = await decode(); const payload = await decode();
if(resp.ok) return payload; if(resp.ok) return payload;
const text = resp.statusText || (typeof payload == 'string' ? payload : null); throw Object.assign(new Error(typeof payload == 'string' ? payload : resp.statusText),
throw (text ? new Error(text) : payload); typeof payload == 'object' ? payload : {});
}); });
} }
} }