mirror of
https://codeberg.org/buzzcode2007/FCC-Project-URLShortener.git
synced 2025-05-21 03:06:34 +00:00
21 lines
No EOL
528 B
JavaScript
Executable file
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} |