import modules errors.js and messaging.js

from https://codeberg.org/buzzcode2007/fcc-project-timestamp/src/branch/master/scripts/messaging.js
This commit is contained in:
buzzcode2007 2025-03-21 08:05:58 +00:00
parent 19f55bfaa2
commit 57d21ccf41
2 changed files with 26 additions and 0 deletions

10
scripts/utilities/errors.js Executable file
View file

@ -0,0 +1,10 @@
class CustomErrors {}
CustomErrors.URL = class URL_Error extends Error {
constructor(message) {
super(message);
this.name = "URL Problem";
};
}
module.exports = {CustomErrors}

16
scripts/utilities/messaging.js Executable file
View file

@ -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}