Creates a NetworkException from a PSR-18 network exception.
Parameters
$psrRequestWordPressAiClientDependenciesPsrHttpMessageRequestInterfacerequired- The PSR-7 request that failed.
$networkExceptionThrowablerequired- The PSR-18 network exception.
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
| Version | Description |
|---|---|
| 0.2.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.