src/js/dthen.js
function(body) {
        var level = this.$level;  // store level then was executed for the given task
                                  // to be used to compute correct the level inside the
                                  // method below

        var task = function() {
            // clean results of execution of a previous task

            this.$busy = 0;
            var pc = this.$taskCounter;
            if (this.$error !== null) {
                this.$taskCounter = 0;  // we have to count the tasks on this level
                this.$level       = level + 1;

                try {
                    if (typeof body === 'function') {
                        body.call(this, this.$error);
                    } else if (body === null) {

                    } else {
                        this.dumpError(this.$error);
                    }
                } catch(e) {
                    this.$level       = level; // restore level
                    this.$taskCounter = pc;    // restore counter
                    throw e;
                }
            }

            if (level === 0) {
                try {
                    this.$schedule();
                } catch(e) {
                    this.error(e);
                }
            } else {
                this.$schedule();
            }

            this.$level       = level; // restore level
            this.$taskCounter = pc;    // restore counter
        };

        if (this.$level > 0) {
            this.$tasks.splice(this.$taskCounter++, 0, task);
        } else {
            this.$tasks.push(task);
        }

        if (this.$level === 0) {
            this.$schedule();
        }

        return this;
    }
function(body) {
        var level = this.$level;  // store level then was executed for the given task
                                  // to be used to compute correct the level inside the
                                  // method below

        var task = function() {
            // clean results of execution of a previous task

            this.$busy = 0;
            var pc = this.$taskCounter;
            if (this.$error !== null) {
                this.$taskCounter = 0;  // we have to count the tasks on this level
                this.$level       = level + 1;

                try {
                    if (typeof body === 'function') {
                        body.call(this, this.$error);
                    } else if (body === null) {

                    } else {
                        this.dumpError(this.$error);
                    }
                } catch(e) {
                    this.$level       = level; // restore level
                    this.$taskCounter = pc;    // restore counter
                    throw e;
                }
            }

            if (level === 0) {
                try {
                    this.$schedule();
                } catch(e) {
                    this.error(e);
                }
            } else {
                this.$schedule();
            }

            this.$level       = level; // restore level
            this.$taskCounter = pc;    // restore counter
        };

        if (this.$level > 0) {
            this.$tasks.splice(this.$taskCounter++, 0, task);
        } else {
            this.$tasks.push(task);
        }

        if (this.$level === 0) {
            this.$schedule();
        }

        return this;
    }
function ( body ) { var level = this . $level ; // store level then was executed for the given task // to be used to compute correct the level inside the // method below var task = function ( ) { // clean results of execution of a previous task this . $busy = 0 ; var pc = this . $taskCounter ; if ( this . $error !== null ) { this . $taskCounter = 0 ; // we have to count the tasks on this level this . $level = level + 1 ; try { if ( typeof body === 'function' ) { body . call ( this , this . $error ) ; } else if ( body === null ) { } else { this . dumpError ( this . $error ) ; } } catch ( e ) { this . $level = level ; // restore level this . $taskCounter = pc ; // restore counter throw e ; } } if ( level === 0 ) { try { this . $schedule ( ) ; } catch ( e ) { this . error ( e ) ; } } else { this . $schedule ( ) ; } this . $level = level ; // restore level this . $taskCounter = pc ; // restore counter } ; if ( this . $level > 0 ) { this . $tasks . splice ( this . $taskCounter ++ , 0 , task ) ; } else { this . $tasks . push ( task ) ; } if ( this . $level === 0 ) { this . $schedule ( ) ; } return this ; }
Method to catch error that has occurred during the doit sequence execution.
@param  {Function} [body] a callback to handle the error. The method
gets an error that has happened as its argument. If there is no argument
the error will be printed in output. If passed argument is null then
no error output is expected.
@chainable
@method catch
Method to catch error that has occurred during the doit sequence execution .