UNPKG

@skyway-sdk/common

Version:

The official Next Generation JavaScript SDK for SkyWay

43 lines 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SkyWayError = void 0; const logger_1 = require("./logger"); const log = new logger_1.Logger('packages/common/src/error.ts'); class SkyWayError extends Error { /**@internal */ constructor(init, logging = true) { super(init.info.detail); this.id = Math.random().toString().slice(2, 10); Object.assign(this, init); this.name = this.info.name; if (logging) { const messages = [ 'SkyWayError', `name:${this.info.name}, detail:${this.info.detail}, solution:${this.info.solution}`, ]; if (this.path) { messages.push(this.path); } if (this.error) { messages.push(this.error); } if (this.payload) { messages.push(this.payload); } messages.push(this.id); log.warn(...messages); } } toJSON() { return { id: this.id, info: this.info, path: this.path, payload: this.payload, error: this.error, stack: this.stack, }; } } exports.SkyWayError = SkyWayError; //# sourceMappingURL=error.js.map