From 1f7661ff121311aa1998bb4d94b312f6754d62f2 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Mon, 6 May 2024 11:51:24 +0800 Subject: [PATCH] Unpackage an error object --- scripts/logging.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/logging.js b/scripts/logging.js index 70087d3..57a7ccb 100644 --- a/scripts/logging.js +++ b/scripts/logging.js @@ -71,6 +71,13 @@ export default class logging { @param {boolean} critical the critical nature */ static async error(ERROR_CODE, ERROR_MESSAGE, ERROR_STACK, critical = true) { + // Depackage the shortcut method of sending the error message. + (!ERROR_MESSAGE && !ERROR_STACK && (typeof ERROR_CODE).includes(`obj`)) ? ( + ERROR_MESSAGE = ERROR_CODE.message, + ERROR_STACK = ERROR_CODE.stack, + ERROR_CODE = ERROR_CODE.name + ) : false; + // Display the error message. console.error('%c%s%c%s%c%s%c\n%s%c', `font-weight: bold;`, ERROR_CODE, ``, `: `, ``, ERROR_MESSAGE, `font-family: monospace;`, ERROR_STACK, ``);