@netleaf/common
Advanced tools
| /** | ||
| * Error class for wrapping caught errors with additional details. | ||
| */ | ||
| export declare class ErrorWrap extends Error { | ||
| #private; | ||
| /** | ||
| * Get inner Error object. | ||
| */ | ||
| get innerError(): Error; | ||
| /** | ||
| * Construct error. | ||
| * @param message | ||
| * @param innerError | ||
| */ | ||
| constructor(message: string, innerError: Error); | ||
| /** | ||
| * Get modified stack trace of error. | ||
| * @param error | ||
| * @param newMessage | ||
| * @private | ||
| */ | ||
| private static stackWithMessage; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.ErrorWrap = void 0; | ||
| const os_1 = require("os"); | ||
| const EndOfLineRegex = /\r?\n/g; | ||
| /** | ||
| * Error class for wrapping caught errors with additional details. | ||
| */ | ||
| class ErrorWrap extends Error { | ||
| /** | ||
| * Inner error backing field. | ||
| * @private | ||
| */ | ||
| #innerError; | ||
| // noinspection JSUnusedGlobalSymbols | ||
| /** | ||
| * Get inner Error object. | ||
| */ | ||
| get innerError() { | ||
| return this.#innerError; | ||
| } | ||
| /** | ||
| * Construct error. | ||
| * @param message | ||
| * @param innerError | ||
| */ | ||
| constructor(message, innerError) { | ||
| super(message); | ||
| if (!innerError) { | ||
| throw new Error("Argument 'innerError' cannot be falsy."); | ||
| } | ||
| this.#innerError = innerError; | ||
| if (!this.stack) { | ||
| Error.captureStackTrace(this, this.constructor); | ||
| } | ||
| const innerName = innerError.constructor.name ? " " + innerError.constructor.name : ""; | ||
| this.stack = this.stack | ||
| + os_1.EOL | ||
| + ErrorWrap.stackWithMessage(innerError, `InnerError${innerName}: ${innerError.message}`); | ||
| } | ||
| /** | ||
| * Get modified stack trace of error. | ||
| * @param error | ||
| * @param newMessage | ||
| * @private | ||
| */ | ||
| static stackWithMessage(error, newMessage) { | ||
| const stack = error.stack || ""; | ||
| const match = error.message.match(EndOfLineRegex); | ||
| const lines = match ? match.length + 1 : 1; | ||
| return newMessage + os_1.EOL | ||
| + stack.split(EndOfLineRegex).slice(lines).join(os_1.EOL); | ||
| } | ||
| } | ||
| exports.ErrorWrap = ErrorWrap; | ||
| //# sourceMappingURL=ErrorWrap.js.map |
| {"version":3,"file":"ErrorWrap.js","sourceRoot":"","sources":["../../src/errors/ErrorWrap.ts"],"names":[],"mappings":";;;AAAA,2BAAoC;AAEpC,MAAM,cAAc,GAAG,QAAQ,CAAC;AAEhC;;GAEG;AACH,MAAa,SAAU,SAAQ,KAAK;IAEnC;;;OAGG;IACM,WAAW,CAAQ;IAE5B,qCAAqC;IACrC;;OAEG;IACH,IAAW,UAAU;QAEpB,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,YAAY,OAAe,EAAE,UAAiB;QAE7C,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,UAAU,EACf;YACC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;SAC1D;QAED,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAE9B,IAAI,CAAC,IAAI,CAAC,KAAK,EACf;YACC,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;SAChD;QAED,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAEvF,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK;cACpB,QAAO;cACP,SAAS,CAAC,gBAAgB,CAAC,UAAU,EAAE,aAAa,SAAS,KAAK,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED;;;;;OAKG;IACK,MAAM,CAAC,gBAAgB,CAAC,KAAY,EAAE,UAAkB;QAE/D,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAClD,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE3C,OAAO,UAAU,GAAG,QAAO;cACxB,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAO,CAAC,CAAC;IAC3D,CAAC;CACD;AA5DD,8BA4DC"} |
| export * from "./errors/ErrorWrap"; |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC"} |
+4
-4
| { | ||
| "name": "@netleaf/common", | ||
| "version": "0.2.0", | ||
| "version": "0.2.1", | ||
| "description": "Common library for NetLeaf application host framework.", | ||
@@ -30,5 +30,5 @@ "main": "dist/index.js", | ||
| "files": [ | ||
| "src/**/*.js", | ||
| "src/**/*.d.ts", | ||
| "src/**/*.js.map" | ||
| "dist/**/*.js", | ||
| "dist/**/*.d.ts", | ||
| "dist/**/*.js.map" | ||
| ], | ||
@@ -35,0 +35,0 @@ "repository": { |
6734
121.44%9
125%96
464.71%