updated xhr error handling
This commit is contained in:
parent
1a4e732fd5
commit
7b2d4ba119
@ -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",
|
||||||
|
@ -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 : {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user