lundi 23 février 2015

No duplicate one try/catch by waterfall function (using async waterfall)

I'm using async waterfall and i've got a question about try/catch error.


I wan't to dodge this syntax method with one global try/catch and no duplicate a try/catch by function :



async.waterfall([
function (callback) {
try {
this.foo() // Method foo doesn't exist so without try/catch node will crash
} catch(ex) {
//print err
}
},
function (callback) {
try {
//Again & again
} catch(ex) {
//print err
}
}
//... function() with try catch ...
], function(err, result) {
//Do something
})

Aucun commentaire:

Enregistrer un commentaire