class CustomError extends Error {
constructor(message) {
super(message);
this.name = this.constructor.name;
}
}
try {
throw new CustomError("Something went wrong");
} catch (error) {
console.log(error.name);
console.log(error instanceof Error);
console.log(error instanceof CustomError);
console.log(typeof error.stack);
} Post #3009
3.36K
CHALLENGE
- ❤ 8
- 👍 7
- 🔥 6