Removed custom errors from xhr helper
All checks were successful
Build / Build NPM Project (push) Successful in 1m14s
Build / Tag Version (push) Successful in 16s
Build / Publish (push) Successful in 23s

This commit is contained in:
Zakary Timson 2024-05-31 12:37:01 -04:00
parent 3ca956e531
commit 07606cd996
3 changed files with 3 additions and 14 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@ztimson/utils", "name": "@ztimson/utils",
"version": "0.4.0", "version": "0.10.2",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@ztimson/utils", "name": "@ztimson/utils",
"version": "0.4.0", "version": "0.10.2",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.12", "@types/jest": "^29.5.12",

View File

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

View File

@ -82,14 +82,3 @@ export class XHR {
}); });
} }
} }
XHR.addInterceptor((resp: Response, next: () => void) => {
const getErr = (e: any) => e.error?.message || e.reason?.message || e.message || e.statusText || e.toString();
if(resp.status == 200) return next();
if(resp.status == 400) throw new BadRequestError(getErr(resp));
if(resp.status == 401) throw new UnauthorizedError(getErr(resp));
if(resp.status == 403) throw new ForbiddenError(getErr(resp));
if(resp.status == 404) throw new NotFoundError(getErr(resp));
if(resp.status == 500) throw new InternalServerError(getErr(resp));
throw new CustomError(getErr(resp), resp.status);
});