exceptionFor example

$this->result->reject($throwable);
        }
    }

    /** * @internal */
    public function _handleFailure($reason): void
    {
        unset($this->currentPromise);
        try {
            $nextYield = $this->generator->throw(Create::exceptionFor($reason));
            // The throw was caught, so keep iterating on the coroutine             $this->nextCoroutine($nextYield);
        } catch (Throwable $throwable) {
            $this->result->reject($throwable);
        }
    }
}
return static function Dcallable $handler) use ($logger$formatter$logLevel): callable {
            return static function DRequestInterface $request, array $options = []) use ($handler$logger$formatter$logLevel) {
                return $handler($request$options)->then(
                    static function D$response) use ($logger$request$formatter$logLevel): ResponseInterface {
                        $message = $formatter->format($request$response);
                        $logger->log($logLevel$message);

                        return $response;
                    },
                    static function D$reason) use ($logger$request$formatter): PromiseInterface {
                        $response = $reason instanceof RequestException ? $reason->getResponse() : null;
                        $message = $formatter->format($request$response, P\Create::exceptionFor($reason));
                        $logger->error($message);

                        return P\Create::rejectionFor($reason);
                    }
                );
            };
        };
    }

    /** * This middleware adds a default content-type if possible, a default * content-length or transfer-encoding header, and the expect header. */
return $p;
    }

    public function otherwise(callable $onRejected): PromiseInterface
    {
        return $this->then(null, $onRejected);
    }

    public function wait(bool $unwrap = true)
    {
        if ($unwrap) {
            throw Create::exceptionFor($this->reason);
        }

        return null;
    }

    public function getState(): string
    {
        return self::REJECTED;
    }

    public function resolve($value): void
    {

        $this->waitIfPending();

        if ($this->result instanceof PromiseInterface) {
            return $this->result->wait($unwrap);
        }
        if ($unwrap) {
            if ($this->state === self::FULFILLED) {
                return $this->result;
            }
            // It's rejected so "unwrap" and throw an exception.             throw Create::exceptionFor($this->result);
        }
    }

    public function getState(): string
    {
        return $this->state;
    }

    public function cancel(): void
    {
        if ($this->state !== self::PENDING) {
            
Home | Imprint | This part of the site doesn't use cookies.