UNPKG

node-musixmatch-api

Version:

Advanced API library for seamless Musixmatch integration.

63 lines 2.98 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); exports.__esModule = true; exports.MusixmatchError = exports.MXMException = void 0; var MXMException = /** @class */ (function (_super) { __extends(MXMException, _super); function MXMException(status_code, requestURL, message) { var _newTarget = this.constructor; var _this = this; var _a; var errorMessage = (_a = message !== null && message !== void 0 ? message : MXMException.codes[status_code]) !== null && _a !== void 0 ? _a : 'Unknown Error'; _this = _super.call(this, errorMessage) || this; _this.status_code = status_code; _this.message = errorMessage; _this.requestURL = requestURL; Object.setPrototypeOf(_this, _newTarget.prototype); _this.name = _this.constructor.name; if (Error.captureStackTrace) { Error.captureStackTrace(_this, _this.constructor); } return _this; } MXMException.prototype.toString = function () { return "Error code: ".concat(this.status_code, " - message: ").concat(this.message, "\nRequest URL: ").concat(this.requestURL); }; MXMException.codes = { 400: 'The request had bad syntax or was inherently impossible to be satisfied.', 401: 'Authentication failed, probably because of invalid/missing API key.', 402: 'The usage limit has been reached, either you exceeded per day requests limits or your balance is insufficient.', 403: 'You are not authorized to perform this operation.', 404: 'The requested resource was not found.', 405: 'The requested method was not found.', 500: 'Ops. Something went wrong.', 503: "Our system is a bit busy at the moment and your request can't be satisfied." }; return MXMException; }(Error)); exports.MXMException = MXMException; var MusixmatchError = /** @class */ (function (_super) { __extends(MusixmatchError, _super); function MusixmatchError(message) { var _this = _super.call(this, message) || this; _this.name = 'MusixmatchError'; return _this; } return MusixmatchError; }(Error)); exports.MusixmatchError = MusixmatchError; //# sourceMappingURL=expectations.js.map