http-error.js 591 B

123456789101112131415161718
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const http_1 = require("http");
  4. /**
  5. * Error subclass to use when an HTTP application error has occurred.
  6. */
  7. class HTTPError extends Error {
  8. constructor(statusCode, message = http_1.STATUS_CODES[statusCode]) {
  9. super(message);
  10. Object.setPrototypeOf(this, new.target.prototype);
  11. this.statusCode = statusCode;
  12. this.code = `E${String(message)
  13. .toUpperCase()
  14. .replace(/\s+/g, '')}`;
  15. }
  16. }
  17. exports.default = HTTPError;
  18. //# sourceMappingURL=http-error.js.map