I agree that catch guards are useful, but they can be implemented in
userland fairly ergonomically:
```
function guard(predicate, callback) {
return function guarded(reason) {
if (!predicate(reason)) {
throw reason;
}
return callback(reason);
};
}
function instanceOf(constructor, callback) {
return guard(reason => reason instanceof constructor, callback);
}
Promise.resolve('invalid')
.then(JSON.parse)
.catch(instanceOf(SyntaxError, reason => {
// do something to handle the syntax error, or perhaps just silence it
}));
```
Regards, Chris
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss