then

Cryptic Swarm crypticswarm at gmail.com
Fri Nov 9 11:55:16 PST 2012


The following should work? Finally expects a block statement, so need to
wrap it in { }...

var info, processed;
try {
    info = JSON.parse(json);
} catch (exception) {
    console.log("Information JSON malformed.");
} finally { try {
    processed = process(info);
} catch (exception) {
    console.log("Error processing information.");
}}

On Fri, Nov 9, 2012 at 1:46 PM, Domenic Denicola <
domenic at domenicdenicola.com> wrote:

> The recent promise discussion prompted me to recall the following
> musing/proposal from Kris Kowal:
>
> https://github.com/kriskowal/q/wiki/On-Exceptions
>
> In short, there's a common code pattern that you can do with promises that
> you can't do with synchronous code. The proposal is for a language
> extension `then` that would allow synchronous code like this:
>
> var info, processed;
> try {
>     info = JSON.parse(json);
> } catch (exception) {
>     console.log("Information JSON malformed.");
> } then {
>     processed = process(info);
> } catch (exception) {
>     console.log("Error processing information.");
> }
>
> Since seeing this, I've run into a lot of situations where a `then` would
> come in handy. I wanted to see if anyone else thought this was a great
> idea, and if it has any chance as an ES7-level proposal.
>
> _______________________________________________
> 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/20121109/c5d2935a/attachment.html>


More information about the es-discuss mailing list