UNPKG

2.27 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _httpStatus = require('http-status');
8
9var _httpStatus2 = _interopRequireDefault(_httpStatus);
10
11var _ExtendableError2 = require('./ExtendableError');
12
13var _ExtendableError3 = _interopRequireDefault(_ExtendableError2);
14
15function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
17function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
19function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
20
21function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
22
23/**
24 * Class representing an API error.
25 * @extends ExtendableError
26 */
27
28var APIError = function (_ExtendableError) {
29 _inherits(APIError, _ExtendableError);
30
31 /**
32 * Creates an API error.
33 * @param {string} message - Error message.
34 * @param {number} status - HTTP status code of error.
35 * @param {boolean} isPublic - Whether the message should be visible to user or not.
36 */
37
38 function APIError(message) {
39 var status = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _httpStatus2.default.INTERNAL_SERVER_ERROR;
40 var isPublic = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
41
42 _classCallCheck(this, APIError);
43
44 return _possibleConstructorReturn(this, (APIError.__proto__ || Object.getPrototypeOf(APIError)).call(this, message, status, isPublic));
45 }
46
47 return APIError;
48}(_ExtendableError3.default);
49
50exports.default = APIError;
51module.exports = exports['default'];
52//# sourceMappingURL=APIError.js.map