NetworkException::fromPsr18NetworkException( WordPressAiClientDependenciesPsrHttpMessageRequestInterface $psrRequest, Throwable $networkException ): self

In this article

Creates a NetworkException from a PSR-18 network exception.

Parameters

$psrRequestWordPressAiClientDependenciesPsrHttpMessageRequestInterfacerequired
The PSR-7 request that failed.
$networkExceptionThrowablerequired
The PSR-18 network exception.

Return

self

Source

public static function fromPsr18NetworkException(RequestInterface $psrRequest, \Throwable $networkException): self
{
    $request = Request::fromPsrRequest($psrRequest);
    $message = sprintf('Network error occurred while sending request to %s: %s', $request->getUri(), $networkException->getMessage());
    $exception = new self($message, 0, $networkException);
    $exception->request = $request;
    return $exception;
}

Changelog

VersionDescription
0.2.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.