ServerException
extends BadResponseException
in package
Exception when a server error is encountered (5xx codes)
Table of Contents
- $handlerContext : array<string|int, mixed>
- $request : RequestInterface
- $response : ResponseInterface|null
- __construct() : mixed
- create() : self
- Factory method to create a new exception with a normalized error message
- getHandlerContext() : array<string|int, mixed>
- Get contextual information about the error from the underlying handler.
- getRequest() : RequestInterface
- Get the request that caused the exception
- getResponse() : ResponseInterface|null
- Get the associated response
- getResponseBodySummary() : string|null
- Get a short summary of the response
- hasResponse() : bool
- Check if a response was received
- wrapException() : RequestException
- Wrap non-RequestExceptions with a RequestException
- obfuscateUri() : UriInterface
- Obfuscates URI if there is a username and a password present
Properties
$handlerContext
private
array<string|int, mixed>
$handlerContext
$request
private
RequestInterface
$request
$response
private
ResponseInterface|null
$response
Methods
__construct()
public
__construct(mixed $message, RequestInterface $request[, ResponseInterface $response = null ][, Exception $previous = null ][, array<string|int, mixed> $handlerContext = [] ]) : mixed
Parameters
- $message : mixed
- $request : RequestInterface
- $response : ResponseInterface = null
- $previous : Exception = null
- $handlerContext : array<string|int, mixed> = []
Return values
mixed —create()
Factory method to create a new exception with a normalized error message
public
static create(RequestInterface $request[, ResponseInterface $response = null ][, Exception $previous = null ][, array<string|int, mixed> $ctx = [] ]) : self
Parameters
- $request : RequestInterface
-
Request
- $response : ResponseInterface = null
-
Response received
- $previous : Exception = null
-
Previous exception
- $ctx : array<string|int, mixed> = []
-
Optional handler context.
Return values
self —getHandlerContext()
Get contextual information about the error from the underlying handler.
public
getHandlerContext() : array<string|int, mixed>
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.
Return values
array<string|int, mixed> —getRequest()
Get the request that caused the exception
public
getRequest() : RequestInterface
Return values
RequestInterface —getResponse()
Get the associated response
public
getResponse() : ResponseInterface|null
Return values
ResponseInterface|null —getResponseBodySummary()
Get a short summary of the response
public
static getResponseBodySummary(ResponseInterface $response) : string|null
Will return null
if the response is not printable.
Parameters
- $response : ResponseInterface
Return values
string|null —hasResponse()
Check if a response was received
public
hasResponse() : bool
Return values
bool —wrapException()
Wrap non-RequestExceptions with a RequestException
public
static wrapException(RequestInterface $request, Exception $e) : RequestException
Parameters
- $request : RequestInterface
- $e : Exception
Return values
RequestException —obfuscateUri()
Obfuscates URI if there is a username and a password present
private
static obfuscateUri(UriInterface $uri) : UriInterface
Parameters
- $uri : UriInterface