From f3d0f88f957a88bd2ecc48907e4ed558a2328c38 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Fri, 12 Nov 2021 15:06:11 +0530 Subject: [PATCH] Make error public --- src/logging/LogItem.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/logging/LogItem.ts b/src/logging/LogItem.ts index 4289aafc..64ed6603 100644 --- a/src/logging/LogItem.ts +++ b/src/logging/LogItem.ts @@ -50,7 +50,7 @@ export type LogCallback = (item: LogItem) => unknown; export class LogItem { public readonly start: number; public logLevel: LogLevel; - private _error: Error | null; + public error: Error | null; public end: number | null; private _values: LogItemValues; private _logger: BaseLogger; @@ -63,7 +63,7 @@ export class LogItem { this.end = null; // (l)abel this._values = typeof labelOrValues === "string" ? {l: labelOrValues} : labelOrValues; - this._error = null; + this.error = null; this.logLevel = logLevel; this._children = null; this._filterCreator = filterCreator; @@ -182,12 +182,12 @@ export class LogItem { // (l)evel l: this.logLevel }; - if (this._error) { + if (this.error) { // (e)rror item.e = { - stack: this._error.stack, - name: this._error.name, - message: this._error.message.split("\n")[0] + stack: this.error.stack, + name: this.error.name, + message: this.error.message.split("\n")[0] }; } if (forced) { @@ -257,7 +257,7 @@ export class LogItem { } catch(err: Error) { - this._error = err; + this.error = err; this.logLevel = LogLevel.Error; this.finish(); return err; @@ -281,8 +281,4 @@ export class LogItem { get logger() { return this._logger; } - - get error() { - return this._error; - } }