Restore exception handling.

@return $this
327678
protected function withExceptionHandling()
    {
        if ($this->previousExceptionHandler) {
            $this->app->instance(ExceptionHandler::class, $this->previousExceptionHandler);
        }

        return $this;
    }
817260
public function check()
    {
        try {
            try {
                $this->result(
                    $this->resource->checker->setTarget($this)->checkTarget(
                        $this
                    )
                );
            } catch (\Exception $exception) {
                report($exception);

                $this->exceptionResult($exception);
            }
        } catch (\Throwable $error) {
            report($error);

            $this->exceptionResult($error);
        }

        $this->moveChecksBackToTarget();

        return $this;
    }
1004662
function install()
    {
        if ($this->error_handler) {
            throw new Exception(sprintf('%s->install() must only be called once', get_class($this)));
        }
        $this->error_handler = new ErrorHandler($this, false, $this->error_types);
        $this->error_handler->registerExceptionHandler();
        $this->error_handler->registerErrorHandler();
        $this->error_handler->registerShutdownFunction();
        return $this;
    }
1065841
public function globalRollback()
    {
        $res = null;

        if ($this->isInDbTransaction()) {
            $res = pg_query($this->pgConn, 'rollback');
            if ($res === false) {
                throw $this->createException();
            }
        }
        $this->dbTransLevel = 0;
        $this->transLevel = 0;
        $this->commitCallbacks = [];

        return $this;
    }
829706
protected function _process()
    {
        if (is_callable($this->_handler)) {
            return $this->_processDelegated();
        }
        $spec = $this->_actual;

        if (!$spec instanceof Specification || $spec->passed() !== null) {
            return $this;
        }

        $closure = function () use ($spec) {
            $spec->reset();
            $spec->process($result);
            $this->_logs = $spec->logs();
            return $this->_passed = $spec->passed();
        };

        try {
            $this->_spin($closure);
        } catch (TimeoutException $e) {
        }
        if ($exception = $spec->log()->exception()) {
            throw $exception;
        }

        $this->_passed = $spec->passed() && ($this->_passed === null ? true : $this->_passed);
        return $this;
    }
1294375
public function restore()
    {
        $retval = [
            'success' => false,
            'data'    => [],
        ];

        if ($this['status'] === 'AVAILABLE') {
            $retval['data']['message'] = 'Node is already available.';

            return $retval;
        }

        $response = self::$httpClient->post(
            self::$account->getMetadataUrl() . "trash/{$this['id']}/restore",
            [
                'headers'    => [
                    'Authorization' => 'Bearer ' . self::$account->getToken()['access_token'],
                ],
                'exceptions' => false,
            ]
        );

        $retval['data'] = json_decode((string)$response->getBody(), true);

        if ($response->getStatusCode() === 200) {
            $retval['success'] = true;
            $this->replace($retval['data']);
            $this->save();
        }

        return $retval;
    }
1370793
public function rollback()
    {
        if (!$this->nested || $this->depth == 1) {
            $this->db->connect()->getConnection()->rollBack();
        }

        $this->depth--;

        return $this;
    }
1067318
public function reset()
    {
        $this->queryType = null;
        $this->offset = 0;
        $this->limit = null;
        $this->joins = array();
        $this->fields = array();
        $this->fromTable = null;
        $this->wheres = array();
        $this->orderBy = null;
        $this->groupBy = array();
        $this->having = array();
        return $this;
    }
574526
public function startWithTrashed()
    {
        $this->reset(new Action(__METHOD__, [], Action::INTERNAL));

        $this->getCurrentPlan()->startWithTrashed();

        return $this;
    }
1000972
public function invoke()
    {
        $args      = func_get_args();
        $retries   = 0;
        $exception = null;
        $return    = null;

        /** @noinspection PhpUnusedLocalVariableInspection */
        $sc = SmartCallable::factory("restore_error_handler");
        set_error_handler(function($type, $message, $file, $line) {
                throw PHPException::factory(
                    $message,
                    $type,
                    $file,
                    $line
                );
            });

        do {
            try {
                $exception = null;
                $return    = call_user_func_array($this->callback, $args);
            } catch (Exception $exception) {
                $this->logger->error($exception->getMessage());
            }
            $action = $this->matchesCondition($return, $exception);
            if ("retry" == $action) {
                $retries++;
            }
        } while("retry" == $action && ($retries < $this->max_retries || -1 === $this->max_retries));
        
        if ($exception && "return" !== $action) {
            throw $exception;
        }
        if ($this->filter) {
            $return = call_user_func($this->filter, $return);
        }
        
        return $return;
    }
515186
public function reset()
    {
        // reset structure
        parent::reset();

        // reset errors
        $this->clearErrors();

        // reset behaviors
        $this->clearBehaviors();

        // init delegates
        $this->initDelegates();

        return $this;
    }
1029854
public function restore()
    {
        if ($this->hidden_at !== null) {
            $this->hidden_at = null;
            $this->hidden_user_id = null;

            $this->raise(new Restored($this));
        }

        return $this;
    }
245398
public function reindexImportedCategories()
    {
        switch ($this->getBehavior()) {
            case Import::BEHAVIOR_DELETE:
                $this->indexDeleteEvents();
                break;
            case Import::BEHAVIOR_REPLACE:
            case Import::BEHAVIOR_APPEND:
            case Import::BEHAVIOR_ADD_UPDATE:

                $this->reindexUpdatedCategories();
                break;
            default:
                throw new \Exception('Unsupported Mode!');
                break;
        }
        return $this;
    }
366761
protected function updatesAfterUnset()
    {
        $this->updateHelpers();
        foreach ($this->rendererAdapters->all() as $ra) {
            $ra->onRestorePreviousRenderer($this);
        }

        return $this;
    }
1278747
final public function rollBack()
    {
        if (!$this->pdo) {
            throw  new Exception('您还没有连接数据库', Exception::CODE_DATABASE_ERROR);
        }
        if ($this->_begintransaction) {
            $this->pdo->rollBack();
            $this->_begintransaction = false;
        }
        return $this;
    }
1257913
public function restore($force = true)
    {
        $ok = $this->handler->restore();

        if (!$ok && $force) {
            throw new Exception("Could not restore settings: No restore point available");
        }

        return $this;
    }
576906
protected function afterDeleteException()
    {
        $this->dispatcher->getEventsManager()->fire(Events::AFTER_DELETE_EXCEPTION, $this);
        return $this->redirectToAction('index');
    }