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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -