javascript - Nodejs Q promise catch never called with passport js -
i'm using passport library node assist me in user signup. i'm using 'q' promise library avoid pyramid of doom go through several asynchronous steps.
everything works fine, until throw error 1 of promised steps. have assumed execution drop .fail
function, handle error , return out of passport failed signup. reason don't understand, .fail
function never gets called. instead, stackdump in browser window , in console.
the controlling code here:
q.fcall(checkemailisfree({'email':email, 'username':username, 'password':password})) .then(checkusernameisfree) .then(registeruser) .then(function (user) { if (user) { logdebug('registered: ' + email); return done(null, user); } else { logdebug('could not register'); return done(null, false); } }) .fail(function (err) { logerror('i never here'); return done(null, false); }) .done();
and here's how i'm throwing, within checkemailisfree
var error = new error('bad times. email in use: ' + email); throw error;
is there overall express / node code somewhere set fast dump out exception somehow? why isn't catch being called? missing?
i think done(onfulfilled, onrejected, onprogress)
can in case. can try:
q.fcall(checkemailisfree({'email':email, 'username':username, 'password':password})) .then(checkusernameisfree) .then(registeruser) .then(function (user) { if (user) { logdebug('registered: ' + email); return done(null, user); } else { logdebug('could not register'); return done(null, false); } }) .done(undefined, function (err) { logerror('error!'); // used in case of reject return done(null, false); });
Comments
Post a Comment