UNPKG

@tgsnake/core

Version:

Pure Telegram MTProto library for nodejs

51 lines (50 loc) 1.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BaseError = void 0; const platform_node_js_1 = require("../platform.node.js"); class BaseError extends Error { message; description; constructor(message) { super(message); } [Symbol.for('nodejs.util.inspect.custom')]() { const toPrint = { _: this.constructor.name, }; for (const key in this) { if (Object.prototype.hasOwnProperty.call(this, key)) { const value = this[key]; if (!key.startsWith('_')) { toPrint[key] = value; } } } Object.setPrototypeOf(toPrint, { stack: this.stack, }); return toPrint; } [Symbol.for('Deno.customInspect')]() { return String((0, platform_node_js_1.inspect)(this[Symbol.for('nodejs.util.inspect.custom')](), { colors: true })); } toJSON() { const toPrint = { _: this.constructor.name, stack: this.stack, }; for (const key in this) { if (Object.prototype.hasOwnProperty.call(this, key)) { const value = this[key]; if (!key.startsWith('_')) { toPrint[key] = typeof value === 'bigint' ? String(value) : value; } } } return toPrint; } toString() { return `[constructor of ${this.constructor.name}] ${JSON.stringify(this, null, 2)}`; } } exports.BaseError = BaseError;