UNPKG

divvy-lib

Version:

A JavaScript API for interacting with Divvy in Node.js and the browser

80 lines 2.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const util_1 = require("util"); const browserHacks = require("./browser-hacks"); class DivvyError extends Error { constructor(message = '', data) { super(message); this.name = browserHacks.getConstructorName(this); this.message = message; this.data = data; if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } } toString() { let result = '[' + this.name + '(' + this.message; if (this.data) { result += ', ' + util_1.inspect(this.data); } result += ')]'; return result; } /* console.log in node uses util.inspect on object, and util.inspect allows us to customize its output: https://nodejs.org/api/util.html#util_custom_inspect_function_on_objects */ inspect() { return this.toString(); } } exports.DivvyError = DivvyError; class DivvydError extends DivvyError { } exports.DivvydError = DivvydError; class UnexpectedError extends DivvyError { } exports.UnexpectedError = UnexpectedError; class LedgerVersionError extends DivvyError { } exports.LedgerVersionError = LedgerVersionError; class ConnectionError extends DivvyError { } exports.ConnectionError = ConnectionError; class NotConnectedError extends ConnectionError { } exports.NotConnectedError = NotConnectedError; class DisconnectedError extends ConnectionError { } exports.DisconnectedError = DisconnectedError; class DivvydNotInitializedError extends ConnectionError { } exports.DivvydNotInitializedError = DivvydNotInitializedError; class TimeoutError extends ConnectionError { } exports.TimeoutError = TimeoutError; class ResponseFormatError extends ConnectionError { } exports.ResponseFormatError = ResponseFormatError; class ValidationError extends DivvyError { } exports.ValidationError = ValidationError; class NotFoundError extends DivvyError { constructor(message = 'Not found') { super(message); } } exports.NotFoundError = NotFoundError; class MissingLedgerHistoryError extends DivvyError { constructor(message) { super(message || 'Server is missing ledger history in the specified range'); } } exports.MissingLedgerHistoryError = MissingLedgerHistoryError; class PendingLedgerVersionError extends DivvyError { constructor(message) { super(message || 'maxLedgerVersion is greater than server\'s most recent ' + ' validated ledger'); } } exports.PendingLedgerVersionError = PendingLedgerVersionError; //# sourceMappingURL=errors.js.map