UNPKG

route4me-node

Version:

Access Route4Me's logistics-as-a-service API using our Node.js SDK

122 lines (95 loc) 3.86 kB
"use strict"; /** * The base type for all error-objects of this SDK * * @category Errors */ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _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; } function _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; } var Route4MeError = function (_Error) { _inherits(Route4MeError, _Error); /** * Create Route4MeError * @param {string} msg [description] * @param {Error} innerError [description] * @return {Route4MeError} [description] * @private * @inner */ function Route4MeError(msg, innerError) { _classCallCheck(this, Route4MeError); var _this = _possibleConstructorReturn(this, (Route4MeError.__proto__ || Object.getPrototypeOf(Route4MeError)).call(this, msg)); _this.innerError = innerError || null; _this.name = "Route4MeError"; // // TODO: use this code!! // Object.defineProperty(this, 'name', { // configurable: true, // enumerable : false, // value : this.constructor.name, // writable : true, // }); return _this; } return Route4MeError; }(Error); /** * Error received from the API-server * * @category Errors */ var Route4MeApiError = function (_Route4MeError) { _inherits(Route4MeApiError, _Route4MeError); /** * Create Route4MeApiError * @param {string} msg [description] * @param {Object} res [description] * @param {Error} innerError [description] * @return {Route4MeApiError} [description] * @private * @inner */ function Route4MeApiError(msg, res, innerError) { _classCallCheck(this, Route4MeApiError); // TODO: remove this line: var _this2 = _possibleConstructorReturn(this, (Route4MeApiError.__proto__ || Object.getPrototypeOf(Route4MeApiError)).call(this, msg, innerError)); _this2.name = "Route4MeApiError"; _this2.statusCode = res.statusCode; _this2.apiPath = res.request.url; return _this2; } return Route4MeApiError; }(Route4MeError); /** * Error occured during internal validation * * @category Errors */ var Route4MeValidationError = function (_Route4MeError2) { _inherits(Route4MeValidationError, _Route4MeError2); /** * Create Route4MeValidationError * @param {string} msg - Message * @param {*} data - Data under consideration * @param {Error} innerError - Error, caused this error * @return {Route4MeValidationError} * @private * @inner */ function Route4MeValidationError(msg, data, innerError) { _classCallCheck(this, Route4MeValidationError); // TODO: remove this line: var _this3 = _possibleConstructorReturn(this, (Route4MeValidationError.__proto__ || Object.getPrototypeOf(Route4MeValidationError)).call(this, msg, innerError)); _this3.name = "Route4MeValidationError"; /** * Data under consideration * @type {*} */ _this3.data = data; return _this3; } return Route4MeValidationError; }(Route4MeError); exports.Route4MeError = Route4MeError; exports.Route4MeApiError = Route4MeApiError; exports.Route4MeValidationError = Route4MeValidationError;