grpc-error-messages
Version:
A collection of grpc error classes with default human-readable messages
201 lines (200 loc) • 8.62 kB
JavaScript
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var ErrorCodes;
(function (ErrorCodes) {
ErrorCodes[ErrorCodes["OK"] = 0] = "OK";
ErrorCodes[ErrorCodes["CANCELLED"] = 1] = "CANCELLED";
ErrorCodes[ErrorCodes["UNKNOWN"] = 2] = "UNKNOWN";
ErrorCodes[ErrorCodes["INVALID_ARGUMENT"] = 3] = "INVALID_ARGUMENT";
ErrorCodes[ErrorCodes["DEADLINE_EXCEEDED"] = 4] = "DEADLINE_EXCEEDED";
ErrorCodes[ErrorCodes["NOT_FOUND"] = 5] = "NOT_FOUND";
ErrorCodes[ErrorCodes["ALREADY_EXISTS"] = 6] = "ALREADY_EXISTS";
ErrorCodes[ErrorCodes["PERMISSION_DENIED"] = 7] = "PERMISSION_DENIED";
ErrorCodes[ErrorCodes["RESOURCE_EXHAUSTED"] = 8] = "RESOURCE_EXHAUSTED";
ErrorCodes[ErrorCodes["FAILED_PRECONDITION"] = 9] = "FAILED_PRECONDITION";
ErrorCodes[ErrorCodes["ABORTED"] = 10] = "ABORTED";
ErrorCodes[ErrorCodes["OUT_OF_RANGE"] = 11] = "OUT_OF_RANGE";
ErrorCodes[ErrorCodes["UNIMPLEMENTED"] = 12] = "UNIMPLEMENTED";
ErrorCodes[ErrorCodes["INTERNAL"] = 13] = "INTERNAL";
ErrorCodes[ErrorCodes["UNAVAILABLE"] = 14] = "UNAVAILABLE";
ErrorCodes[ErrorCodes["DATA_LOSS"] = 15] = "DATA_LOSS";
ErrorCodes[ErrorCodes["UNAUTHENTICATED"] = 16] = "UNAUTHENTICATED";
})(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));
var UnknownError = (function (_super) {
__extends(UnknownError, _super);
function UnknownError(message) {
var _this = _super.call(this, message || UnknownError.MESSAGE) || this;
_this.code = ErrorCodes.UNKNOWN;
return _this;
}
UnknownError.MESSAGE = 'Unknown error.';
return UnknownError;
}(Error));
exports.UnknownError = UnknownError;
var InvalidArgumentError = (function (_super) {
__extends(InvalidArgumentError, _super);
function InvalidArgumentError(message) {
var _this = _super.call(this, message || InvalidArgumentError.MESSAGE) || this;
_this.code = ErrorCodes.INVALID_ARGUMENT;
return _this;
}
InvalidArgumentError.MESSAGE = 'The client specified an invalid argument.';
return InvalidArgumentError;
}(Error));
exports.InvalidArgumentError = InvalidArgumentError;
var DeadlineExceededError = (function (_super) {
__extends(DeadlineExceededError, _super);
function DeadlineExceededError(message) {
var _this = _super.call(this, message || DeadlineExceededError.MESSAGE) || this;
_this.code = ErrorCodes.DEADLINE_EXCEEDED;
return _this;
}
DeadlineExceededError.MESSAGE = 'The deadline expired before the operation could complete.';
return DeadlineExceededError;
}(Error));
exports.DeadlineExceededError = DeadlineExceededError;
var NotFoundError = (function (_super) {
__extends(NotFoundError, _super);
function NotFoundError(message) {
var _this = _super.call(this, message || NotFoundError.MESSAGE) || this;
_this.code = ErrorCodes.NOT_FOUND;
return _this;
}
NotFoundError.MESSAGE = 'The requested item was not found.';
return NotFoundError;
}(Error));
exports.NotFoundError = NotFoundError;
var AlreadyExistsError = (function (_super) {
__extends(AlreadyExistsError, _super);
function AlreadyExistsError(message) {
var _this = _super.call(this, message || AlreadyExistsError.MESSAGE) || this;
_this.code = ErrorCodes.ALREADY_EXISTS;
return _this;
}
AlreadyExistsError.MESSAGE = 'The item being created already exists.';
return AlreadyExistsError;
}(Error));
exports.AlreadyExistsError = AlreadyExistsError;
var PermissionDeniedError = (function (_super) {
__extends(PermissionDeniedError, _super);
function PermissionDeniedError(message) {
var _this = _super.call(this, message || PermissionDeniedError.MESSAGE) || this;
_this.code = ErrorCodes.PERMISSION_DENIED;
return _this;
}
PermissionDeniedError.MESSAGE = 'Insufficient permissions.';
return PermissionDeniedError;
}(Error));
exports.PermissionDeniedError = PermissionDeniedError;
var UnauthenticatedError = (function (_super) {
__extends(UnauthenticatedError, _super);
function UnauthenticatedError(message) {
var _this = _super.call(this, message || UnauthenticatedError.MESSAGE) || this;
_this.code = ErrorCodes.UNAUTHENTICATED;
return _this;
}
UnauthenticatedError.MESSAGE = 'Authentication required.';
return UnauthenticatedError;
}(Error));
exports.UnauthenticatedError = UnauthenticatedError;
var ResourceExhaustedError = (function (_super) {
__extends(ResourceExhaustedError, _super);
function ResourceExhaustedError(message) {
var _this = _super.call(this, message || ResourceExhaustedError.MESSAGE) || this;
_this.code = ErrorCodes.RESOURCE_EXHAUSTED;
return _this;
}
ResourceExhaustedError.MESSAGE = 'The server resource has been exhausted.';
return ResourceExhaustedError;
}(Error));
exports.ResourceExhaustedError = ResourceExhaustedError;
var FailedPreconditionError = (function (_super) {
__extends(FailedPreconditionError, _super);
function FailedPreconditionError(message) {
var _this = _super.call(this, message || FailedPreconditionError.MESSAGE) || this;
_this.code = ErrorCodes.FAILED_PRECONDITION;
return _this;
}
FailedPreconditionError.MESSAGE = 'The operation requested was rejected by the server.';
return FailedPreconditionError;
}(Error));
exports.FailedPreconditionError = FailedPreconditionError;
var AbortedError = (function (_super) {
__extends(AbortedError, _super);
function AbortedError(message) {
var _this = _super.call(this, message || AbortedError.MESSAGE) || this;
_this.code = ErrorCodes.ABORTED;
return _this;
}
AbortedError.MESSAGE = 'The operation was aborted.';
return AbortedError;
}(Error));
exports.AbortedError = AbortedError;
var OutOfRangeError = (function (_super) {
__extends(OutOfRangeError, _super);
function OutOfRangeError(message) {
var _this = _super.call(this, message || OutOfRangeError.MESSAGE) || this;
_this.code = ErrorCodes.OUT_OF_RANGE;
return _this;
}
OutOfRangeError.MESSAGE = 'The operation was attempted past the valid range.';
return OutOfRangeError;
}(Error));
exports.OutOfRangeError = OutOfRangeError;
var UnimplementedError = (function (_super) {
__extends(UnimplementedError, _super);
function UnimplementedError(message) {
var _this = _super.call(this, message || UnimplementedError.MESSAGE) || this;
_this.code = ErrorCodes.UNIMPLEMENTED;
return _this;
}
UnimplementedError.MESSAGE = 'The operation is not implemented.';
return UnimplementedError;
}(Error));
exports.UnimplementedError = UnimplementedError;
var InternalError = (function (_super) {
__extends(InternalError, _super);
function InternalError(message) {
var _this = _super.call(this, message || InternalError.MESSAGE) || this;
_this.code = ErrorCodes.INTERNAL;
return _this;
}
InternalError.MESSAGE = 'Internal server error.';
return InternalError;
}(Error));
exports.InternalError = InternalError;
var UnavailableError = (function (_super) {
__extends(UnavailableError, _super);
function UnavailableError(message) {
var _this = _super.call(this, message || UnavailableError.MESSAGE) || this;
_this.code = ErrorCodes.UNAVAILABLE;
return _this;
}
UnavailableError.MESSAGE = 'The service is currently unavailable.';
return UnavailableError;
}(Error));
exports.UnavailableError = UnavailableError;
var DataLossError = (function (_super) {
__extends(DataLossError, _super);
function DataLossError(message) {
var _this = _super.call(this, message || DataLossError.MESSAGE) || this;
_this.code = ErrorCodes.DATA_LOSS;
return _this;
}
DataLossError.MESSAGE = 'Unrecoverable data loss or corruption.';
return DataLossError;
}(Error));
exports.DataLossError = DataLossError;