UNPKG

@agnostack/requestd

Version:

Please contact agnoStack via info@agnostack.com for any questions

28 lines 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ClientError = void 0; const utils_1 = require("./utils"); class ClientError extends Error { constructor(message, params) { const { code, response, error } = params; const { message: wrappedMessage } = (0, utils_1.ensureObject)(error); const errorMessage = `${message}${wrappedMessage ? `. ${wrappedMessage}` : ''}`; super(errorMessage); this.code = code; this.response = response; this.error = error; this.name = 'ClientError'; Object.setPrototypeOf(this, ClientError.prototype); // Capture the current stacktrace and store it in the property "this.stack". By // providing the implementationContext argument, we will remove the current // constructor (or the optional factory function) line-item from the stacktrace; this // is good because it will reduce the implementation noise in the stack property. // -- // Read More: https://code.google.com/p/v8-wiki/wiki/JavaScriptStackTraceApi#Stack_trace_collection_for_custom_exceptions if (Error.captureStackTrace) { Error.captureStackTrace(this.error || this, ClientError); } } } exports.ClientError = ClientError; //# sourceMappingURL=ClientError.js.map