Custom Error Classes in JavaScript
🟢 Beginner Level | JavaScript Core Syntax
📖 Definition
Custom Error classes extend native Error to provide domain-specific error attributes and stack traces.
âš¡ Code Example
class ValidationError extends Error {
constructor(message) {
super(message);
this.name = "ValidationError";
}
}
throw new ValidationError("Invalid email address");