File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,18 +97,42 @@ var Flow = function (){
9797
9898Flow . prototype = {
9999
100+ /**
101+ * Default error handler.
102+ * @private
103+ * @this {Flow}
104+ * @param {Error } err Error to throw.
105+ */
106+ _error : function ( err ) {
107+ throw err ;
108+ } ,
109+
110+
111+
112+ /**
113+ * Check if the stack handler is the `next` handler.
114+ * @private
115+ * @this {Flow}
116+ * @param {String } str The handler to be check.
117+ */
100118 _is_next : function ( str ) {
101119 return / s e l f \[ ' _ ' \+ n e x t _ t y p e \] \. a p p l y \( s e l f , s l i c e \. c a l l \( a r g u m e n t s \) \) ; / g. test ( str ) ;
102120 } ,
103121
122+
123+
104124/**
105125 * Call the current series function and remove it.
106126 * @private
107127 * @this {Flow}
108128 * @param {Array } args Arguments to be passed to the current series function.
109129 */
110130 _run_series : function ( args ) {
111- this . _series . shift ( ) . apply ( this , args ) ;
131+ try {
132+ this . _series . shift ( ) . apply ( this , args ) ;
133+ } catch ( err ) {
134+ this . _error ( err ) ;
135+ }
112136 } ,
113137
114138
@@ -145,7 +169,6 @@ Flow.prototype = {
145169 * @param {Array } args Arguments to be added to the current parallel function.
146170 */
147171 _run_parallel : function ( args ) {
148-
149172 var self = this ;
150173 var parallel_args = this . _parallel_args . shift ( ) ;
151174 var args_form_last_task = args ;
@@ -357,6 +380,12 @@ Flow.prototype = {
357380 return this ;
358381 } ,
359382
383+ error : function ( callback ) {
384+ this . _error = callback ;
385+
386+ return this ;
387+ } ,
388+
360389
361390
362391/**
You can’t perform that action at this time.
0 commit comments