It would be really nice to be able to write
try {
// some code
} catch (error instanceof MyCustomError) {
// handle the error
} catch (error instanceof AnotherCustomError) {
// handle the other error
}
instead of the more verbose
try {
// some code
} catch (error) {
if (error instanceof MyCustomError) {
// handle the error
} else if (error instanceof AnotherCustomError) {
// handle the other error
} else {
throw error;
}
}