From 57d21ccf41e711161a3cfca86fa76921b9628b36 Mon Sep 17 00:00:00 2001 From: buzzcode2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Fri, 21 Mar 2025 08:05:58 +0000 Subject: [PATCH] import modules errors.js and messaging.js from https://codeberg.org/buzzcode2007/fcc-project-timestamp/src/branch/master/scripts/messaging.js --- scripts/utilities/errors.js | 10 ++++++++++ scripts/utilities/messaging.js | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100755 scripts/utilities/errors.js create mode 100755 scripts/utilities/messaging.js diff --git a/scripts/utilities/errors.js b/scripts/utilities/errors.js new file mode 100755 index 0000000..5da24fd --- /dev/null +++ b/scripts/utilities/errors.js @@ -0,0 +1,10 @@ +class CustomErrors {} + +CustomErrors.URL = class URL_Error extends Error { + constructor(message) { + super(message); + this.name = "URL Problem"; + }; +} + +module.exports = {CustomErrors} \ No newline at end of file diff --git a/scripts/utilities/messaging.js b/scripts/utilities/messaging.js new file mode 100755 index 0000000..6ac89f7 --- /dev/null +++ b/scripts/utilities/messaging.js @@ -0,0 +1,16 @@ +class Messaging { + /* + Return an error message. + + @param {object} INSTANCE - The response instance + @param {object} ERROR - The error object + */ + static exception (INSTANCE, ERROR) { + let MESSAGE = {error: ERROR}; + INSTANCE.json(MESSAGE); + console.error(ERROR); + return (MESSAGE); + } +} + +module.exports = {Messaging} \ No newline at end of file