FCC-Project_File-Metadata/scripts/utilities/errors.js

40 lines
No EOL
1 KiB
JavaScript

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