FCC-Project_Exercise-Tracker/scripts/utilities/messaging.JS
2025-04-11 01:15:17 +00:00

20 lines
No EOL
517 B
JavaScript

const CustomErrors = require(`./errors.JS`);
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": {}};
[`name`, `message`, `stack`].forEach((KEY) => {
MESSAGE[`error`][KEY] = ERROR[KEY];
})
INSTANCE.json(MESSAGE); console.error(ERROR);
return (MESSAGE);
}
}
module.exports = Messaging;