Make error public

This commit is contained in:
RMidhunSuresh 2021-11-12 15:06:11 +05:30
parent 2ddd2d16ed
commit f3d0f88f95

View file

@ -50,7 +50,7 @@ export type LogCallback = (item: LogItem) => unknown;
export class LogItem { export class LogItem {
public readonly start: number; public readonly start: number;
public logLevel: LogLevel; public logLevel: LogLevel;
private _error: Error | null; public error: Error | null;
public end: number | null; public end: number | null;
private _values: LogItemValues; private _values: LogItemValues;
private _logger: BaseLogger; private _logger: BaseLogger;
@ -63,7 +63,7 @@ export class LogItem {
this.end = null; this.end = null;
// (l)abel // (l)abel
this._values = typeof labelOrValues === "string" ? {l: labelOrValues} : labelOrValues; this._values = typeof labelOrValues === "string" ? {l: labelOrValues} : labelOrValues;
this._error = null; this.error = null;
this.logLevel = logLevel; this.logLevel = logLevel;
this._children = null; this._children = null;
this._filterCreator = filterCreator; this._filterCreator = filterCreator;
@ -182,12 +182,12 @@ export class LogItem {
// (l)evel // (l)evel
l: this.logLevel l: this.logLevel
}; };
if (this._error) { if (this.error) {
// (e)rror // (e)rror
item.e = { item.e = {
stack: this._error.stack, stack: this.error.stack,
name: this._error.name, name: this.error.name,
message: this._error.message.split("\n")[0] message: this.error.message.split("\n")[0]
}; };
} }
if (forced) { if (forced) {
@ -257,7 +257,7 @@ export class LogItem {
} }
catch(err: Error) { catch(err: Error) {
this._error = err; this.error = err;
this.logLevel = LogLevel.Error; this.logLevel = LogLevel.Error;
this.finish(); this.finish();
return err; return err;
@ -281,8 +281,4 @@ export class LogItem {
get logger() { get logger() {
return this._logger; return this._logger;
} }
get error() {
return this._error;
}
} }