UNPKG

raiden-api-sdk

Version:

SDK for interacting with the Raiden API

61 lines (60 loc) 2.51 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 (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var http_status_codes_1 = __importDefault(require("http-status-codes")); exports.BAD_REQUEST = 'BAD_REQUEST'; exports.PAYMENT_REQUIRED = 'PAYMENT_REQUIRED'; exports.NOT_FOUND = 'NOT_FOUND'; exports.CONFLICT = 'CONFLICT'; exports.INTERNAL_RAIDEN_NODE_ERROR = 'INTERNAL_RAIDEN_NODE_ERROR'; exports.NOT_IMPLEMENTED = 'NOT_IMPLEMENTED'; var RaidenAPIError = /** @class */ (function (_super) { __extends(RaidenAPIError, _super); function RaidenAPIError(err) { var _this = this; var errors = err.response.errors; _this = _super.call(this, Array.isArray(errors) ? errors[0] : errors) || this; Error.captureStackTrace(_this, RaidenAPIError); _this.name = RaidenAPIError.name; _this.cause = err; _this.errors = err.response.errors; switch (err.status) { case http_status_codes_1.default.BAD_REQUEST: _this.type = exports.BAD_REQUEST; break; case http_status_codes_1.default.PAYMENT_REQUIRED: _this.type = exports.PAYMENT_REQUIRED; break; case http_status_codes_1.default.NOT_FOUND: _this.type = exports.NOT_FOUND; break; case http_status_codes_1.default.CONFLICT: _this.type = exports.CONFLICT; break; case http_status_codes_1.default.NOT_IMPLEMENTED: _this.type = exports.NOT_IMPLEMENTED; break; default: _this.type = exports.INTERNAL_RAIDEN_NODE_ERROR; break; } return _this; } return RaidenAPIError; }(Error)); exports.RaidenAPIError = RaidenAPIError;