blob: d1e1c3df8a8787a57793fed112a164f640b58ea6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkStatus = exports.HTTPError = void 0;
class HTTPError extends Error {
constructor(response) {
super(`HTTP Error: ${response.status} ${response.statusText}`);
this.response = response;
this.statusCode = response.status;
this.location = response.headers?.get('Location') || undefined;
}
}
exports.HTTPError = HTTPError;
const checkStatus = (response) => {
if (response.ok) {
return response;
}
else {
throw new HTTPError(response);
}
};
exports.checkStatus = checkStatus;
|