Set the previous throwable.

@param \Throwable $throwable the previous throwable

@return $this
489520
protected function setPrevious($throwable)
    {
        if ($throwable) {
            $this->previous = static::fromPHPThrowable($this->config, $throwable);
        }

        return $this;
    }
591557
private function setOriginalSoapExceptionContent(\Exception $previous = null)
    {
        if (is_object($previous) && $previous instanceof \SoapFault) {
            $this->originalMessage = $previous->faultstring;
            $this->originalCode = $previous->faultcode;
        }

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

        return $this;
    }
52424
public function handle(\Throwable $throwable)
    {
        // Being Emitter Aware we are bound to comply to the Events Definition.
        // self::emitDebugEvent() will return null when no Emitter is present. Otherwise we'll get the Exception
        // after it's been processed by Event Listeners so we need to overwrite it here.
        if (null !== $response = $this->emitDebugEvent(definitions\Events::DEBUG_THROWABLE_BEFORE, $throwable)) {
            $throwable = $response;
        }

        // First of all run all Conditions. The method will return true if we are to prevent further execution.
        if ($this->runConditions($throwable)) {
            return;
        }

        // Whether we will quit after the loop. Set to true when one of the Delegates returns a QUIT signal.
        $quit = false;

        // Get the applicable Delegates.
        $delegates = array_intersect_key($this->delegates, array_flip($this->getApplicable()));

        // If we've got anything to call later on, proceed.
        if (!empty($delegates)) {
            // Sort the Delegates by their priority.
            $this->sort($delegates);

            // Inspect the Exception we got, which will give us an Inspector instance we can pass along.
            $inspector = $this->inspect($throwable);

            // Walk through all applicable Delegates and let them handle the Exception until done or one of them
            // returns a STOP/QUIT signal.
            foreach ($delegates as $v) {
                // If we're dealing with a Delegate instance, call its handle() method. If it's a casual callable,
                // call it and pass the Inspector as the only argument.
                $response = $v['delegate'] instanceof interfaces\Delegate
                    ? $v['delegate']->handle($inspector)
                    : call_user_func($v['delegate'], $inspector);

                // Make it easier for inheriting children to act upon the response if it's not a signal.
                $response = $this->handleDelegateResponse($response, $inspector);

                // Let's check if we've got a signal as response. If it's QUIT, we'll set a flag and handle it
                // after the loop.
                if (($response & definitions\Signals::QUIT) === definitions\Signals::QUIT) {
                    $quit = true;
                }

                // QUIT includes STOP so this will catch both situations.
                if (($response & definitions\Signals::STOP) === definitions\Signals::STOP) {
                    break;
                }
            }
        }

        // Now that we are done looping, time to attempt to emit the appropriate Event.
        $this->emitDebugEvent(definitions\Events::DEBUG_THROWABLE_AFTER, $throwable);

        // If we were told to quit and the Handler allows this, do eet.
        if ($quit and $this->doesAllowQuit()) {
            exit;
        }

        // Clear all lists. See the notes for {@see self::whitelist()} and {@see self::blacklist()} why Delegates
        // should be listed, for consistency, by Conditions *only*.
        $this->applicable = null;
        $this->whitelist  = $this->blacklist = [];
    }
1147061
@Override
  public FutureResultImpl<T> setFailure(Throwable throwable) {
    this.throwable = throwable;
    failed = true;
    checkCallHandler();
    return this;
  }
669783
public function exceptionHandler(\Throwable $exception)
    {
        if ($exception instanceof ResponseCode) {
            try {
                $out = $this->render($exception->getCode(), [], $exception->display());
            } catch (\Throwable $exception) {
                return $this->exceptionHandler($exception);
            }

            // debug on dev / display trace
            if (!(AbstractApp::env() != AbstractApp::PRODUCTION && ob_get_length() > 0)) {
                self::response()->addHeader('Content-Type', $this->getErrorContentType());
            }

            self::response()->setStatus($exception->getCode());
            self::response()->setBody($out);
            HttpApp::instance()->end();
        } else {
            Handler::log($exception);

            if (AbstractApp::env() != AbstractApp::PRODUCTION) {
                Handler::exceptionHandler($exception);
            } else {
                $throw = new ResponseCode($exception->getMessage(), 500, $exception);
                $this->exceptionHandler($throw);
            }
        }

        return true;
    }
910771
public function handle(\Throwable $throwable)
    {
        try {
            $response = $this->doHandler($throwable);
        } catch (\Throwable $e) {
            $response = $this->handleThrowtable($e);
        }

        return $response;
    }
793483
protected function namespaceHandler(Throwable $exception) : ?Throwable
    {
        if ($this->namespace && $exception instanceof ClientException) {
            return $exception->withNamespace($this->namespace);
        }

        return null;
    }
669507
public static function exceptionHandler(\Throwable $throwable)
    {
        self::showError($throwable);

        Log::error((string)$throwable);
    }
111967
public function map($callable)
    {
        if (!$this->isCallable($callable)) {
            throw new ArrayObjectException(ArrayObjectException::MSG_INVALID_PARAM, [
                '$callable',
                'a callable function or method'
            ]);
        }

        $this->val(array_map($callable, $this->val()));

        return $this;
    }
942734
public function setCallbackWrapper(?callable $callbackWrapper): callable
    {
        $previousWrapper = $this->callbackWrapper;
        $this->callbackWrapper = $callbackWrapper ?? function (callable $callback, ItemInterface $item, bool &$save, CacheInterface $pool, \Closure $setMetadata, ?LoggerInterface $logger) {
            return $callback($item, $save);
        };

        return $previousWrapper;
    }
723705
public function doHandler(\Throwable $throwable)
    {
        $exceptionClass = get_class($throwable);
        $collector      = ExceptionHandlerCollector::getCollector();
        $isNotExistHandler = !isset($collector[$exceptionClass]) && !isset($collector[\Exception::class]);
        if (empty($collector) || $isNotExistHandler) {
            return $this->handleThrowtable($throwable);
        }

        if(isset($collector[$exceptionClass])){
            list($classBeanName, $methodName) = $collector[$exceptionClass];
        }else{
            list($classBeanName, $methodName) = $collector[\Exception::class];
        }

        $handler    = App::getBean($classBeanName);
        $bindParams = $this->getBindParams($classBeanName, $methodName, $throwable);
        $response   = PhpHelper::call([$handler, $methodName], $bindParams);
        if ($response instanceof ResponseInterface) {
            return $response;
        }

        throw new \Exception("the handler of exception must be return the object of response!");
    }
136426
public function notifyException($throwable, callable $callback = null)
    {
        $report = Report::fromPHPThrowable($this->config, $throwable);

        $this->notify($report, $callback);
    }
771937
public function setValue($value)
    {
        $this->value = $value;
        if ($value instanceof ValueAwareInterface) {
            $this->value = $value->getFormValue();
        }
        return $this;
    }
764606
public function setPHPThrowable($throwable)
    {
        if (!$throwable instanceof Throwable && !$throwable instanceof Exception) {
            throw new InvalidArgumentException('The throwable must implement Throwable or extend Exception.');
        }

        $this->setName(get_class($throwable))
             ->setMessage($throwable->getMessage())
             ->setStacktrace(Stacktrace::fromBacktrace($this->config, $throwable->getTrace(), $throwable->getFile(), $throwable->getLine()));

        if (method_exists($throwable, 'getPrevious')) {
            $this->setPrevious($throwable->getPrevious());
        }

        return $this;
    }
566715
public function reset()
    {
        $reflection = new \ReflectionClass(static::class);
        foreach ($reflection->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
            if (!$property->isStatic()) {
                $this->{$property->getName()} = null;
            }
        }
        return $this;
    }
1175910
public function _and(callable $callable = null)
    {
        $history = $this->whereNeedAddAndOrOr;
        $this->whereNeedAddAndOrOr = 1;

        if (is_callable($callable)) {
            $history === 0 && $this->whereNeedAddAndOrOr = 0;
            $this->lBrackets();
            call_user_func($callable, $this);
            $this->rBrackets();
        }

        return $this;
    }