Future::catchError PHP Method

catchError() public method

public catchError ( $onreject, $test = NULL )
    public function catchError($onreject, $test = NULL)
    {
        if (is_callable($test)) {
            $self = $this;
            return $this->then(NULL, function ($e) use($self, $onreject, $test) {
                if (call_user_func($test, $e)) {
                    return $self->then(NULL, $onreject);
                } else {
                    throw $e;
                }
            });
        }
        return $this->then(NULL, $onreject);
    }