UNPKG

bungienetplatformjs

Version:
92 lines (69 loc) 2.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extendableErrorClass = require("extendable-error-class"); var _extendableErrorClass2 = _interopRequireDefault(_extendableErrorClass); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; } /** * Exception type generated by BungieNet.* classes */ var Error = function (_ExtendableError) { _inherits(Error, _ExtendableError); /** * @param {String} message - error message * @param {Error.codes} code - error code * @param {*} data - any associated data */ function Error() { var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ""; var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Error.codes.unknown; var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; _classCallCheck(this, Error); var _this = _possibleConstructorReturn(this, (Error.__proto__ || Object.getPrototypeOf(Error)).call(this, message)); _this.code = code; _this.data = data; return _this; } return Error; }(_extendableErrorClass2.default); /** * Associated exception codes for BungieNet.Error exceptions * @type {Object} */ exports.default = Error; Error.codes = { /** * Cookies cannot be found * @type {Number} */ noCookieByName: 1, /** * Network failure * @type {Number} */ networkError: 2, /** * Value required for X-CSRF header not found * @type {Number} */ noCsrfToken: 3, /** * Response from bungie.net could not be parsed as valid JSON * @type {Number} */ corruptResponse: 4, /** * An invalid cookie provider was set or used * @type {Number} */ noCookieProvider: 5, /** * Generic error * @type {Number} */ unknown: 6 };