Syntax sugar similar to Go error handling would be much more useful, at
least for me :
let [err, result] = try JSON.parse('invalid');
On Oct 30, 2015 5:33 PM, "Mohsen Azimi" <[email protected]> wrote:
> This would be nice with `await` but how would you specify the boundary?
>
> ```
> let json = try await (await fetch('file'.json).json());
> ```
> should that throw on `.json()` now?
>
> On Fri, Oct 30, 2015 at 6:48 AM Michael McGlothlin <
> [email protected]> wrote:
>
>> It'd be nice if you could just do try {} without all the catch and
>> finally stuff because about half the time the logic is simpler if I can
>> just put all the error handling code in one place at the end. I end up with
>> a lot of empty catch (err){} laying around waiting to break something. And
>> using one large try/catch/finally block isn't really workable either
>> because I don't want an exception to break the flow.
>>
>> Of course it'd be nice if there was syntax to shorten
>>
>> let test = undefined;
>> try {
>> test = testSomething();
>> } catch ( err ) {}
>>
>> into just
>>
>> let test = try testSomething() || undefined;
>>
>> Possibly where without the `|| undefined` test would contain an Error
>> instance that's flagged as thrown or such. An Error flagged as thrown
>> should evaluate as false so that logic ops work.
>> _______________________________________________
>> es-discuss mailing list
>> [email protected]
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss