FCC-Project-URLShortener/scripts/utilities/messaging.js
buzzcode2007 36cb74ac72 Update messaging errors
Should change the error name when a URL-related error is found
2025-03-23 07:49:43 +00:00

21 lines
No EOL
528 B
JavaScript
Executable file

const CustomErrors = require(`./errors`).CustomErrors;
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};
if (ERROR instanceof CustomErrors.URL) {
MESSAGE[`error`] = 'invalid url';
};
INSTANCE.json(MESSAGE);
console.error(ERROR);
return (MESSAGE);
}
}
module.exports = {Messaging}