diff --git a/scripts/utilities/errors.js b/scripts/utilities/errors.js index 5da24fd..ce8231d 100755 --- a/scripts/utilities/errors.js +++ b/scripts/utilities/errors.js @@ -1,10 +1,25 @@ class CustomErrors {} CustomErrors.URL = class URL_Error extends Error { - constructor(message) { - super(message); + constructor(message, URL) { + super((message) ? message : `invalid url`); this.name = "URL Problem"; + this.stack = URL; }; } +CustomErrors.DBProblem = class DB_Error extends Error { + constructor(message) { + super(message); + this.name = "Database Problem" + } +} + +CustomErrors.HashProblem = class DB_Error extends Error { + constructor(message) { + super(message); + this.name = "Hash Problem" + } +} + module.exports = {CustomErrors} \ No newline at end of file diff --git a/scripts/utilities/messaging.js b/scripts/utilities/messaging.js index 6ac89f7..12305a4 100755 --- a/scripts/utilities/messaging.js +++ b/scripts/utilities/messaging.js @@ -1,3 +1,5 @@ +const CustomErrors = require(`./errors`).CustomErrors; + class Messaging { /* Return an error message. @@ -7,6 +9,9 @@ class Messaging { */ 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);