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",
"version": "0.12.2",
"version": "0.12.3",
"description": "Utility library",
"author": "Zak Timson",
"license": "MIT",

View File

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