Skip to content

Commit

Permalink
[WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
jongpie committed Sep 20, 2024
1 parent b35d0b8 commit f2fb679
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,26 @@ const LogEntryBuilder = class {
* @return {LogEntryBuilder} The same instance of `LogEntryBuilder`, useful for chaining methods
*/
setError(error) {
if (!error) {
return this.setExceptionDetails(error);
}

/**
* @description Sets the log entry event's exception fields
* @param {Error} exception The instance of a JavaScript `Error` object to use, or an Apex HTTP error to use
* @return {LogEntryBuilder} The same instance of `LogEntryBuilder`, useful for chaining methods
*/
setExceptionDetails(exception) {
if (!exception) {
return this;
}

this.#componentLogEntry.error = {};
if (error.body) {
this.#componentLogEntry.error.message = error.body.message;
this.#componentLogEntry.error.stackTrace = error.body.stackTrace;
this.#componentLogEntry.error.type = error.body.exceptionType;
if (exception.body) {
this.#componentLogEntry.error.message = exception.body.message;
this.#componentLogEntry.error.stackTrace = exception.body.stackTrace;
this.#componentLogEntry.error.type = exception.body.exceptionType;
} else {
this.#componentLogEntry.error.message = error.message;
this.#componentLogEntry.error.message = exception.message;
this.#componentLogEntry.error.stackTrace = new LoggerStackTrace().parse(error);
this.#componentLogEntry.error.type = 'JavaScript.' + error.name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ const LoggerService = class {
});
}

exception(message, exception, originStackTraceError) {
this.error(message, originStackTraceError).setExceptionDetails(exception);
this.saveLog();
throw exception;
}

error(message, originStackTraceError) {
return this._newEntry('ERROR', message, originStackTraceError);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
// See LICENSE file or go to https://github.com/jongpie/NebulaLogger for full license details. //
//------------------------------------------------------------------------------------------------//

/*
This class handles enqueueing & executing any provided functions in the order that
they're specified, regardless if they're sync or async functions
*/

/* eslint-disable @lwc/lwc/no-dupe-class-members */
export class LoggerServiceTaskQueue {
#isProcessing = false;
Expand Down

0 comments on commit f2fb679

Please sign in to comment.