updated xhr error handling
This commit is contained in:
parent
1a4e732fd5
commit
7b2d4ba119
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ztimson/utils",
|
||||
"version": "0.12.2",
|
||||
"version": "0.12.3",
|
||||
"description": "Utility library",
|
||||
"author": "Zak Timson",
|
||||
"license": "MIT",
|
||||
|
@ -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 : {});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user