Return proxied Throwable.

@return \Error|\Exception
550539
public function toThrowable()
    {
        $class = $this->class;
        $prev  = $this->prev !== null ? $this->prev->toThrowable() : $this->prev;

        return new $class($this->message, 0, $prev);
    }
1154420
protected function proxy() {
        if (!$this->context) {
            $this->context = new SyncStreamContext(
                $this->version,
                $this->solution['serviceSid'],
                $this->solution['sid']
            );
        }

        return $this->context;
    }
137524
protected function proxy() {
        if (!$this->context) {
            $this->context = new ConnectAppContext(
                $this->version,
                $this->solution['accountSid'],
                $this->solution['sid']
            );
        }

        return $this->context;
    }
499683
protected function proxy() {
        if (!$this->context) {
            $this->context = new NumberContext($this->version, $this->solution['number']);
        }

        return $this->context;
    }
394984
protected function proxy() {
        if (!$this->context) {
            $this->context = new ApplicationContext(
                $this->version,
                $this->solution['accountSid'],
                $this->solution['sid']
            );
        }

        return $this->context;
    }
1124391
protected function proxy() {
        if (!$this->context) {
            $this->context = new UserBindingContext(
                $this->version,
                $this->solution['serviceSid'],
                $this->solution['userSid'],
                $this->solution['sid']
            );
        }

        return $this->context;
    }
926281
public function get_proxied_instance() : \core_course_category {
        if (!$this->category) {
            $this->category = \core_course_category::get($this->id, IGNORE_MISSING, true);
        }
        return $this->category;
    }
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!");
    }
1362534
protected function proxy() {
        if (!$this->context) {
            $this->context = new ServiceContext($this->version, $this->solution['sid']);
        }

        return $this->context;
    }
437746
public function transform(\Throwable $exception): \Throwable
    {
        if (false === $exception instanceof BadResponseException) {
            return new ApiException($exception);
        }

        try {
            /** @var BadResponseException $exception */
            $errorResponse = $exception->getResponse();
            if (null === $errorResponse) {
                return new ApiException($exception);
            }
            $errorStatusCode = $errorResponse->getStatusCode();
            $bodyString = (string) $errorResponse->getBody();
            $bodyArray = json_decode($bodyString, true);
            $errorStatusName = '';
            if (\is_array($bodyArray) && array_key_exists('error', $bodyArray)) {
                $errorStatusName = $bodyArray['error'];
            }
        } catch (\Exception $e) {
            return new ApiException($exception);
        }

        return $this->transformByStatusCodeAndName($exception, $errorStatusCode, $errorStatusName);
    }
126008
protected function proxy() {
        if (!$this->context) {
            $this->context = new WorkspaceContext($this->version, $this->solution['sid']);
        }

        return $this->context;
    }
102569
protected function proxy() {
        if (!$this->context) {
            $this->context = new ShortCodeContext(
                $this->version,
                $this->solution['accountSid'],
                $this->solution['sid']
            );
        }

        return $this->context;
    }
673528
protected function proxy() {
        if (!$this->context) {
            $this->context = new FactorContext(
                $this->version,
                $this->solution['serviceSid'],
                $this->solution['identity'],
                $this->solution['sid']
            );
        }

        return $this->context;
    }
1187099
protected function getSliceWithException()
	{
		return function ( $stack, $pipe )
		{
			return function ( $passable ) use ( $stack, $pipe )
			{
				if ( $pipe instanceof Closure )
				{
					// If the pipe is an instance of a Closure, we will just call it directly but
					// otherwise we'll resolve the pipes out of the container and call it with
					// the appropriate method and arguments, returning the results back out.
					return call_user_func( $pipe, $passable, $stack );
				}
				elseif ( !is_object( $pipe ) )
				{
					list( $name, $parameters ) = $this->parsePipeString( $pipe );

					// If the pipe is a string we will parse the string and resolve the class out
					// of the dependency injection container. We can then build a callable and
					// execute the pipe function giving in the parameters that are required.
					$pipe = UniversalBuilder::resolve( $name );

					if ( is_null( $pipe ) )
						$pipe = UniversalBuilder::buildClass( $name );

					if ( is_null( $pipe ) )
						throw new PipelineException( "Busted pipeline at [" . $name . "]. There is water everywhere and all repairmen have quit because of budget cuts. But I blame the failure to resolve." );

					$parameters = array_merge( [$passable, $stack], $parameters );
				}
				else
				{
					// If the pipe is already an object we'll just make a callable and pass it to
					// the pipe as-is. There is no need to do any extra parsing and formatting
					// since the object we're given was already a fully instantiated object.
					$parameters = [$passable, $stack];
				}

				return call_user_func_array( [$pipe, $this->method], $parameters );
			};
		};
	}
1315456
protected function proxy() {
        if (!$this->context) {
            $this->context = new CommandContext($this->version, $this->solution['sid']);
        }

        return $this->context;
    }
1253839
public function answer(): callable
    {
        return function ($self, $arguments) {
            foreach ($this->iterations as $iteration) {
                foreach ($iteration->requests as $request) {
                    $this->invoker->callWith(
                        $request->callback(),
                        $request->finalArguments($self, $arguments)
                    );
                }

                if ($iteration instanceof GeneratorYieldFromIteration) {
                    foreach ($iteration->values as $key => $value) {
                        if ($key instanceof InstanceHandle) {
                            $key = $key->get();
                        }

                        if ($value instanceof InstanceHandle) {
                            $value = $value->get();
                        }

                        yield $key => $value;
                    }
                } else {
                    if ($iteration->hasKey) {
                        yield $iteration->key => $iteration->value;
                    } elseif ($iteration->hasValue) {
                        yield $iteration->value;
                    } else {
                        yield;
                    }
                }
            }

            foreach ($this->requests as $request) {
                $this->invoker->callWith(
                    $request->callback(),
                    $request->finalArguments($self, $arguments)
                );
            }

            if ($this->exception) {
                throw $this->exception;
            }

            if ($this->returnsSelf) {
                return $self;
            }

            if (null !== $this->returnsArgument) {
                return $arguments->get($this->returnsArgument);
            }

            return $this->returnValue;
        };
    }
1276464
protected function requestExceptionHandler(Throwable $exception) : ?Throwable
    {
        if ($exception instanceof RequestException) {
            if (
                $exception->hasResponse() &&
                $exception->getResponse()->hasError()
            ) {
                return new BadRemoteCallException($exception->getResponse());
            }

            return new ConnectionException(
                $exception->getRequest(),
                $exception->getMessage(),
                $exception->getCode()
            );
        }

        return null;
    }