git-documentdb
Version:
Offline-first database that syncs with Git
142 lines • 4.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrappingRemoteEngineError = exports.RemoteErr = exports.RemoteEngine = void 0;
/**
* RemoteEngine
*
* @public
*/
exports.RemoteEngine = {};
class BaseError extends Error {
constructor(e) {
super(e);
this.name = new.target.name;
Object.setPrototypeOf(this, new.target.prototype);
}
}
/**
* RemoteError
*
* @public
*/
var RemoteErr;
(function (RemoteErr) {
/**
* @privateRemarks
* Copy error message from parent
*/
class CannotConnectError extends BaseError {
constructor(mes) {
super('');
this.message = mes;
}
}
RemoteErr.CannotConnectError = CannotConnectError;
class HTTPError401AuthorizationRequired extends BaseError {
constructor(mes) {
super('');
this.message = mes;
}
}
RemoteErr.HTTPError401AuthorizationRequired = HTTPError401AuthorizationRequired;
class HTTPError403Forbidden extends BaseError {
constructor(mes) {
super('');
this.message = mes;
}
}
RemoteErr.HTTPError403Forbidden = HTTPError403Forbidden;
class HTTPError404NotFound extends BaseError {
constructor(mes) {
super('');
this.message = mes;
}
}
RemoteErr.HTTPError404NotFound = HTTPError404NotFound;
class InvalidAuthenticationTypeError extends BaseError {
constructor(mes) {
super('');
this.message = mes;
}
}
RemoteErr.InvalidAuthenticationTypeError = InvalidAuthenticationTypeError;
class InvalidGitRemoteError extends BaseError {
constructor(mes) {
super('');
this.message = mes;
}
}
RemoteErr.InvalidGitRemoteError = InvalidGitRemoteError;
class InvalidRepositoryURLError extends BaseError {
constructor(mes) {
super('');
this.message = mes;
}
}
RemoteErr.InvalidRepositoryURLError = InvalidRepositoryURLError;
class InvalidSSHKeyPathError extends BaseError {
constructor(mes) {
super('');
this.message = mes;
}
}
RemoteErr.InvalidSSHKeyPathError = InvalidSSHKeyPathError;
class InvalidURLFormatError extends BaseError {
constructor(mes) {
super('');
this.message = mes;
}
}
RemoteErr.InvalidURLFormatError = InvalidURLFormatError;
class NetworkError extends BaseError {
constructor(mes) {
super('');
this.message = mes;
}
}
RemoteErr.NetworkError = NetworkError;
class UnfetchedCommitExistsError extends BaseError {
constructor(mes) {
super('');
this.message = mes;
}
}
RemoteErr.UnfetchedCommitExistsError = UnfetchedCommitExistsError;
})(RemoteErr = exports.RemoteErr || (exports.RemoteErr = {}));
/**
* wrappingRemoteEngineError
*
* @internal
*/
// eslint-disable-next-line complexity
function wrappingRemoteEngineError(remoteEngineError) {
// Do not use 'instanceof' to compare git-documentdb-remote-errors
switch (remoteEngineError.name) {
case 'CannotConnectError':
return new RemoteErr.CannotConnectError(remoteEngineError.message);
case 'HTTPError401AuthorizationRequired':
return new RemoteErr.HTTPError401AuthorizationRequired(remoteEngineError.message);
case 'HTTPError403Forbidden':
return new RemoteErr.HTTPError403Forbidden(remoteEngineError.message);
case 'HTTPError404NotFound':
return new RemoteErr.HTTPError404NotFound(remoteEngineError.message);
case 'InvalidAuthenticationTypeError':
return new RemoteErr.InvalidAuthenticationTypeError(remoteEngineError.message);
case 'InvalidGitRemoteError':
return new RemoteErr.InvalidGitRemoteError(remoteEngineError.message);
case 'InvalidRepositoryURLError':
return new RemoteErr.InvalidRepositoryURLError(remoteEngineError.message);
case 'InvalidSSHKeyPathError':
return new RemoteErr.InvalidSSHKeyPathError(remoteEngineError.message);
case 'InvalidURLFormatError':
return new RemoteErr.InvalidURLFormatError(remoteEngineError.message);
case 'NetworkError':
return new RemoteErr.NetworkError(remoteEngineError.message);
case 'UnfetchedCommitExistsError':
return new RemoteErr.UnfetchedCommitExistsError(remoteEngineError.message);
default:
return new Error(remoteEngineError.message);
}
}
exports.wrappingRemoteEngineError = wrappingRemoteEngineError;
//# sourceMappingURL=remote_engine.js.map