Skip to content

Latest commit

 

History

History
218 lines (86 loc) · 3.16 KB

ClientException.md

File metadata and controls

218 lines (86 loc) · 3.16 KB

ClientException

Exception when a client error is encountered (4xx codes)

Inherited methods

__construct

public __construct(string $message, \Psr\Http\Message\RequestInterface $request, \Psr\Http\Message\ResponseInterface $response = null, \Throwable $previous = null, array $handlerContext = []): mixed

Parameters:

Parameter Type Description
$message string
$request \Psr\Http\Message\RequestInterface
$response \Psr\Http\Message\ResponseInterface
$previous \Throwable
$handlerContext array

hasResponse

Check if a response was received

public hasResponse(): bool

getResponse

Get the associated response

public getResponse(): ?\Psr\Http\Message\ResponseInterface

wrapException

Wrap non-RequestExceptions with a RequestException

public static wrapException(\Psr\Http\Message\RequestInterface $request, \Throwable $e): \GuzzleHttp\Exception\RequestException
  • This method is static.

Parameters:

Parameter Type Description
$request \Psr\Http\Message\RequestInterface
$e \Throwable

create

Factory method to create a new exception with a normalized error message

public static create(\Psr\Http\Message\RequestInterface $request, \Psr\Http\Message\ResponseInterface $response = null, \Throwable|null $previous = null, array $handlerContext = [], \GuzzleHttp\BodySummarizerInterface|null $bodySummarizer = null): self
  • This method is static.

Parameters:

Parameter Type Description
$request \Psr\Http\Message\RequestInterface Request sent
$response \Psr\Http\Message\ResponseInterface Response received
$previous \Throwable|null Previous exception
$handlerContext array Optional handler context
$bodySummarizer \GuzzleHttp\BodySummarizerInterface|null Optional body summarizer

obfuscateUri

Obfuscates URI if there is a username and a password present

private static obfuscateUri(\Psr\Http\Message\UriInterface $uri): \Psr\Http\Message\UriInterface
  • This method is static.

Parameters:

Parameter Type Description
$uri \Psr\Http\Message\UriInterface

getRequest

Get the request that caused the exception

public getRequest(): \Psr\Http\Message\RequestInterface

getHandlerContext

Get contextual information about the error from the underlying handler.

public getHandlerContext(): array

The contents of this array will vary depending on which handler you are using. It may also be just an empty array. Relying on this data will couple you to a specific handler, but can give more debug information when needed.