diff --git a/scripts/utilities/errors.js b/scripts/utilities/errors.js new file mode 100644 index 0000000..5960fe1 --- /dev/null +++ b/scripts/utilities/errors.js @@ -0,0 +1,40 @@ +class CustomErrors {} + +CustomErrors.URL = class URL_Error extends Error { + constructor(message, URL) { + super((message) ? message : `invalid url`); + this.name = "URL Problem"; + this.stack = URL; + }; +} + +CustomErrors.Data = class Data_Problem extends Error { + constructor(message, data) { + super(message); + this.name = "Data-related Problem"; + this.stack = data; + } +} + +CustomErrors.Data.Missing = class DataMissing_Problem extends CustomErrors.Data { + constructor(data) { + super("The required data is missing."); + this.name = `Missing Information`; + } +} + +CustomErrors.Data.Incorrect = class DataIncorrect_Problem extends CustomErrors.Data { + constructor(data) { + super("The data is incorrect."); + this.name = `Incorrect Information`; + } +} + +CustomErrors.DBProblem = class DB_Error extends Error { + constructor(message) { + super(message); + this.name = "Database Problem" + } +} + +module.exports = CustomErrors \ No newline at end of file