acebase-client
Version:
Client to connect to an AceBase realtime database server
27 lines • 1.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.NOT_CONNECTED_ERROR_MESSAGE = exports.AceBaseRequestError = void 0;
class AceBaseRequestError extends Error {
constructor(request, response, code, message = 'unknown error') {
super(message);
this.request = request;
this.response = response;
this.code = code;
this.message = message;
}
get isNetworkError() {
// No response: network error, or blocked by the browser because of incorrect CORS settings
return this.response === null;
}
get isServerError() {
// 408: Request Timeout, 429: Too Many Requests, 500: Internal Server Error, 502: Bad Gateway, 503: Service Unavailable, 504: Gateway Timeout
return this.response !== null && [408, 429, 500, 502, 503, 504].some((code) => { var _a; return [(_a = this.response) === null || _a === void 0 ? void 0 : _a.statusCode, this.code].includes(code); });
}
get isPermissionError() {
// 401: Unauthorized, 403: Forbidden
return this.response !== null && ([401, 403]).some((code) => { var _a; return [(_a = this.response) === null || _a === void 0 ? void 0 : _a.statusCode, this.code].includes(code); });
}
}
exports.AceBaseRequestError = AceBaseRequestError;
exports.NOT_CONNECTED_ERROR_MESSAGE = 'remote database is not connected'; //'AceBaseClient is not connected';
//# sourceMappingURL=error.js.map