then

François REMY francois.remy.dev at outlook.com
Fri Nov 9 12:33:09 PST 2012


|
|  The idea is to not do the processing if the JSON parsing fails.
|

Then, why not just nest your try's? For readability reasons?

    var info, processed;
    try {
        info = JSON.parse(json);
        try {
            processed = process(info);
        } catch(ex) {
            ...
        }
    } catch (ex) {
        ...
    }

If it's the case, you could maybe use a Promise-like approach? With a bit of 
coding, you could probably even get something like

    val info, processed;
    trySequence(=> {
        info = JSON.parse(json);
    }).catch(ex => {
        ...
    }).then(=> {
        processed = process(info);
    }).catch(ex => {
        ...
    }).;




More information about the es-discuss mailing list