UNPKG

service-model

Version:

An object oriented web service framework inspired by Windows Communication Foundation.

38 lines (37 loc) 1.35 kB
var httpStatusCode_1 = require("./httpStatusCode"); /** * An error message that sets the HTTP status code. When an operation passes a HttpError to it's callback, the * HttpStatusCode is used to set the status of the HTTP response. The details of the error are not passed to the client. */ var HttpError = (function () { function HttpError(statusCodeOrMessage, message) { /** * The name of the error. */ this.name = "HttpError"; var statusCode; if (arguments.length == 1) { if (typeof statusCodeOrMessage === "number") { statusCode = statusCodeOrMessage; } else { message = statusCodeOrMessage; } } else { statusCode = statusCodeOrMessage; } if (!statusCode) { statusCode = httpStatusCode_1.HttpStatusCode.InternalServerError; } this.message = message; this.statusCode = statusCode; Error.call(this, message); Error.captureStackTrace(this, this.constructor); } return HttpError; })(); exports.HttpError = HttpError; // TypeScript declares Error as an Interface instead of a class so use prototypical inheritance HttpError.prototype = Object.create(Error.prototype); HttpError.prototype.constructor = HttpError;