UNPKG

typescript-rest

Version:
188 lines 8.46 kB
'use strict'; var __extends = (this && this.__extends) || (function () { var 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 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 server_types_1 = require("./server-types"); /** * Represents a BAD REQUEST error. The request could not be understood by the * server due to malformed syntax. The client SHOULD NOT repeat the request * without modifications. */ var BadRequestError = (function (_super) { __extends(BadRequestError, _super); function BadRequestError(message) { var _this = _super.call(this, 'BadRequestError', 400, message || 'Bad Request') || this; Object['setPrototypeOf'](_this, BadRequestError.prototype); return _this; } return BadRequestError; }(server_types_1.HttpError)); exports.BadRequestError = BadRequestError; /** * Represents an UNAUTHORIZED error. The request requires user authentication. The response * MUST include a WWW-Authenticate header field containing a challenge applicable to the * requested resource. */ var UnauthorizedError = (function (_super) { __extends(UnauthorizedError, _super); function UnauthorizedError(message) { var _this = _super.call(this, 'UnauthorizedError', 401, message || 'Unauthorized') || this; Object['setPrototypeOf'](_this, UnauthorizedError.prototype); return _this; } return UnauthorizedError; }(server_types_1.HttpError)); exports.UnauthorizedError = UnauthorizedError; /** * Represents a FORBIDEN error. The server understood the request, but is refusing to * fulfill it. Authorization will not help and the request SHOULD NOT be repeated. */ var ForbidenError = (function (_super) { __extends(ForbidenError, _super); function ForbidenError(message) { var _this = _super.call(this, 'ForbidenError', 403, message || 'Forbiden') || this; // Object.setPrototypeOf(this, ForbidenError.prototype); // this['__proto__'] = ForbidenError.prototype; Object['setPrototypeOf'](_this, ForbidenError.prototype); return _this; } return ForbidenError; }(server_types_1.HttpError)); exports.ForbidenError = ForbidenError; /** * Represents a NOT FOUND error. The server has not found anything matching * the Request-URI. No indication is given of whether the condition is temporary * or permanent. The 410 (GoneError) status code SHOULD be used if the server knows, * through some internally configurable mechanism, that an old resource is permanently * unavailable and has no forwarding address. * * This error is commonly used when * the server does not wish to reveal exactly why the request has been refused, * or when no other response is applicable. */ var NotFoundError = (function (_super) { __extends(NotFoundError, _super); function NotFoundError(message) { var _this = _super.call(this, 'NotFoundError', 404, message || 'Not Found') || this; Object['setPrototypeOf'](_this, NotFoundError.prototype); return _this; } return NotFoundError; }(server_types_1.HttpError)); exports.NotFoundError = NotFoundError; /** * Represents a METHOD NOT ALLOWED error. The method specified in the Request-Line is not allowed for * the resource identified by the Request-URI. The response MUST include an Allow header * containing a list of valid methods for the requested resource. */ var MethodNotAllowedError = (function (_super) { __extends(MethodNotAllowedError, _super); function MethodNotAllowedError(message) { var _this = _super.call(this, 'MethodNotAllowedError', 405, message || 'Method Not Allowed') || this; Object['setPrototypeOf'](_this, MethodNotAllowedError.prototype); return _this; } return MethodNotAllowedError; }(server_types_1.HttpError)); exports.MethodNotAllowedError = MethodNotAllowedError; /** * Represents a NOT ACCEPTABLE error. The resource identified by the request is only capable of * generating response entities which have content characteristics not acceptable according * to the accept headers sent in the request. */ var NotAcceptableError = (function (_super) { __extends(NotAcceptableError, _super); function NotAcceptableError(message) { var _this = _super.call(this, 'NotAcceptableError', 406, message || 'Not Acceptable') || this; Object['setPrototypeOf'](_this, NotAcceptableError.prototype); return _this; } return NotAcceptableError; }(server_types_1.HttpError)); exports.NotAcceptableError = NotAcceptableError; /** * Represents a CONFLICT error. The request could not be completed due to a * conflict with the current state of the resource. */ var ConflictError = (function (_super) { __extends(ConflictError, _super); function ConflictError(message) { var _this = _super.call(this, 'ConflictError', 409, message || 'Conflict') || this; Object['setPrototypeOf'](_this, ConflictError.prototype); return _this; } return ConflictError; }(server_types_1.HttpError)); exports.ConflictError = ConflictError; /** * Represents a GONE error. The requested resource is no longer available at the server * and no forwarding address is known. This condition is expected to be considered * permanent. Clients with link editing capabilities SHOULD delete references to * the Request-URI after user approval. If the server does not know, or has * no facility to determine, whether or not the condition is permanent, the * error 404 (NotFoundError) SHOULD be used instead. This response is * cacheable unless indicated otherwise. */ var GoneError = (function (_super) { __extends(GoneError, _super); function GoneError(message) { var _this = _super.call(this, 'GoneError', 410, message || 'Gone') || this; Object['setPrototypeOf'](_this, GoneError.prototype); return _this; } return GoneError; }(server_types_1.HttpError)); exports.GoneError = GoneError; /** * Represents an UNSUPPORTED MEDIA TYPE error. The server is refusing to service the request * because the entity of the request is in a format not supported by the requested resource * for the requested method. */ var UnsupportedMediaTypeError = (function (_super) { __extends(UnsupportedMediaTypeError, _super); function UnsupportedMediaTypeError(message) { var _this = _super.call(this, 'UnsupportedMediaTypeError', 415, message || 'Unsupported Media Type') || this; Object['setPrototypeOf'](_this, UnsupportedMediaTypeError.prototype); return _this; } return UnsupportedMediaTypeError; }(server_types_1.HttpError)); exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError; /** * Represents an INTERNAL SERVER error. The server encountered an unexpected condition * which prevented it from fulfilling the request. */ var InternalServerError = (function (_super) { __extends(InternalServerError, _super); function InternalServerError(message) { var _this = _super.call(this, 'InternalServerError', 500, message || 'Internal Server Error') || this; Object['setPrototypeOf'](_this, InternalServerError.prototype); return _this; } return InternalServerError; }(server_types_1.HttpError)); exports.InternalServerError = InternalServerError; /** * Represents a NOT IMPLEMENTED error. The server does not support the functionality required * to fulfill the request. This is the appropriate response when the server does not recognize * the request method and is not capable of supporting it for any resource. */ var NotImplementedError = (function (_super) { __extends(NotImplementedError, _super); function NotImplementedError(message) { var _this = _super.call(this, 'NotImplementedError', 501, message || 'Not Implemented') || this; Object['setPrototypeOf'](_this, NotImplementedError.prototype); return _this; } return NotImplementedError; }(server_types_1.HttpError)); exports.NotImplementedError = NotImplementedError; //# sourceMappingURL=server-errors.js.map