Removed custom errors from xhr helper
This commit is contained in:
11
src/xhr.ts
11
src/xhr.ts
@ -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);
|
||||
});
|
||||
|
Reference in New Issue
Block a user