From 36cb74ac7204115b6a939e250d5164d5f97d692c Mon Sep 17 00:00:00 2001 From: buzzcode2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sun, 23 Mar 2025 07:49:43 +0000 Subject: [PATCH] Update messaging errors Should change the error name when a URL-related error is found --- scripts/utilities/errors.js | 19 +++++++++++++++++-- scripts/utilities/messaging.js | 5 +++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/scripts/utilities/errors.js b/scripts/utilities/errors.js index 5da24fd..ce8231d 100755 --- a/scripts/utilities/errors.js +++ b/scripts/utilities/errors.js @@ -1,10 +1,25 @@ class CustomErrors {} CustomErrors.URL = class URL_Error extends Error { - constructor(message) { - super(message); + constructor(message, URL) { + super((message) ? message : `invalid url`); this.name = "URL Problem"; + this.stack = URL; }; } +CustomErrors.DBProblem = class DB_Error extends Error { + constructor(message) { + super(message); + this.name = "Database Problem" + } +} + +CustomErrors.HashProblem = class DB_Error extends Error { + constructor(message) { + super(message); + this.name = "Hash Problem" + } +} + module.exports = {CustomErrors} \ No newline at end of file diff --git a/scripts/utilities/messaging.js b/scripts/utilities/messaging.js index 6ac89f7..12305a4 100755 --- a/scripts/utilities/messaging.js +++ b/scripts/utilities/messaging.js @@ -1,3 +1,5 @@ +const CustomErrors = require(`./errors`).CustomErrors; + class Messaging { /* Return an error message. @@ -7,6 +9,9 @@ class Messaging { */ static exception (INSTANCE, ERROR) { let MESSAGE = {error: ERROR}; + if (ERROR instanceof CustomErrors.URL) { + MESSAGE[`error`] = 'invalid url'; + }; INSTANCE.json(MESSAGE); console.error(ERROR); return (MESSAGE);