You shouldn't throw exception in a callback.
Instead throwing of that exception call 
cb(error)



On Thursday, 17 December 2015 04:40:56 UTC+3:30, AndDM wrote:
>
> Hi, i've this code:
>
> module.exports.run = function(event, context, cb) {
>   myclass.queryAsync(...)
>   .then(function (results) {
>     if (results.field === "test") {
>       throw "error";
>     } else {
>       return cb(null, "success");
>     }
>   })
>   .catch(function (err) {
>     return cb(err)
>   });
> };
>
> for promise i'm using bluebirdjs and i've attached this code to a mocha 
> test. If function give back a success, the test passes without problems. If 
> the test has errors, the stdout give back: Unhandled rejection null, the 
> mocha test goes on and then stops with exceeded timeout limit.
>
> My mocha test:
>   before("Description", function(done) {
>     require('path').run(event.options, {}, function (err, results) {
>       if (err) {
>         throw err;
>       }
>       done();
>     });
>   });
>   
>
> Some suggestions about that?
> Thanks for your time.
> Best regards
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/90e298f9-2e8d-47a2-948b-739b6b5e2eb5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to