FCC-Project_Exercise-Tracker/scripts/utilities/errors.JS
2025-04-10 22:51:14 +08:00

47 lines
No EOL
1.2 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. The stack contains the received data.");
this.name = `${this.name}: Missing Information`;
}
}
CustomErrors.Data.Incorrect = class DataIncorrect_Problem extends CustomErrors.Data {
constructor(data) {
super("The data is incorrect.");
this.name = `${this.name}: Incorrect Information`;
}
}
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