Error-Type Specific try/catch Blocks

Michał Wadas michalwadas at gmail.com
Fri May 27 15:13:14 UTC 2016


I still can't see why it's superior to standardizing SpiderMonkey
non-standard syntax.

```
try { ...
} catch(e if e instanceof Error) {

}
```

I think it's rather inferior, because your doesn't allow C#-like exception
filters. It saves you 14 characters, but limits your "easy" filters to
`instanceof`.

To quote article on C# exception filters:

> For example, let’s say you are writing code to perform some operation
against a dependency, and that dependency will throw an exception with a
*bool* property that tells you whether the operation *IsRetryable*.
> Now, let’s say that as we’re calling this dependency, we want to be able
to retry any error that has *IsRetryable == true* up to three times, then
abandon if it throws a fourth time.

I think it's legitimate use case and why can't we kill two birds with one
stone? Moreover, I think it's bad idea to add static typing to language in
only one place (catch clauses).


On Fri, May 27, 2016 at 11:05 AM, Arthur Stolyar <nekr.fabula at gmail.com>
wrote:

> Something wrong with prev link.
> https://github.com/zenparsing/es-typed-catch
> On May 27, 2016 12:00, "Arthur Stolyar" <nekr.fabula at gmail.com> wrote:
>
>> If something, here seems to be another similar proposal:
>> https://github.com/zenparsing/es-typed-catch
>>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160527/d03a9898/attachment-0001.html>


More information about the es-discuss mailing list