File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -128,6 +128,10 @@ Flow.prototype = {
128128 * @param {Array } args Arguments to be passed to the current series function.
129129 */
130130 _run_series : function ( args ) {
131+ if ( args . length && args [ 0 ] instanceof Error ) {
132+ return this . _error ( args [ 0 ] ) ;
133+ }
134+
131135 try {
132136 this . _series . shift ( ) . apply ( this , args ) ;
133137 } catch ( err ) {
Original file line number Diff line number Diff line change @@ -351,5 +351,40 @@ module.exports = {
351351 callback ( ) ;
352352 } , 150 ) ;
353353 } ) ;
354+ } ,
355+
356+ 'error handeling' : function ( callback ) {
357+ var flow = new Flow ( 5 , 6 , 7 ) ;
358+
359+ flow . series ( function ( x , y , z , next ) {
360+ setTimeout ( function ( ) {
361+ x . should . equal ( 7 ) ;
362+ y . should . equal ( 6 ) ;
363+ z . should . equal ( 7 ) ;
364+ next ( new Error ( 'Error found' ) ) ;
365+ } , 200 ) ;
366+ } , 7 ) .
367+
368+ series ( function ( x , y , z , next ) {
369+ setTimeout ( function ( ) {
370+ x . should . equal ( 11 ) ;
371+ y . should . equal ( 10 ) ;
372+ z . should . equal ( 55 ) ;
373+ next ( 1000 ) ;
374+ } , 100 ) ;
375+ } , 9 , 10 , 55 ) .
376+
377+ error ( function ( err ) {
378+ console . log ( 'error handeling' , err ) ;
379+ } ) .
380+
381+ end ( function ( x ) {
382+ setTimeout ( function ( ) {
383+ x . should . equal ( 1000 ) ;
384+
385+ console . log ( 'this shouldn\t be seen' ) ;
386+ callback ( ) ;
387+ } , 150 ) ;
388+ } ) ;
354389 }
355390} ;
You can’t perform that action at this time.
0 commit comments