PHP Class GuzzleHttp\Exception\RequestException

Inheritance: extends TransferException
Show file Open project: guzzle/guzzle Class Usage Examples

Public Methods

Method Description
__construct ( $message, Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response = null, Exception $previous = null, array $handlerContext = [] )
create ( Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response = null, Exception $previous = null, array $ctx = [] ) : self Factory method to create a new exception with a normalized error message
getHandlerContext ( ) : array Get contextual information about the error from the underlying handler.
getRequest ( ) : Psr\Http\Message\RequestInterface Get the request that caused the exception
getResponse ( ) : Psr\Http\Message\ResponseInterface | null Get the associated response
getResponseBodySummary ( Psr\Http\Message\ResponseInterface $response ) : string | null Get a short summary of the response
hasResponse ( ) : boolean Check if a response was received
wrapException ( Psr\Http\Message\RequestInterface $request, Exception $e ) : RequestException Wrap non-RequestExceptions with a RequestException

Private Methods

Method Description
obfuscateUri ( Psr\Http\Message\UriInterface $uri ) : Psr\Http\Message\UriInterface Obfuscates URI if there is an username and a password present

Method Details

__construct() public method

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

create() public static method

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, Exception $previous = null, array $ctx = [] ) : self
$request Psr\Http\Message\RequestInterface Request
$response Psr\Http\Message\ResponseInterface Response received
$previous Exception Previous exception
$ctx array Optional handler context.
return self

getHandlerContext() public method

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.
public getHandlerContext ( ) : array
return array

getRequest() public method

Get the request that caused the exception
public getRequest ( ) : Psr\Http\Message\RequestInterface
return Psr\Http\Message\RequestInterface

getResponse() public method

Get the associated response
public getResponse ( ) : Psr\Http\Message\ResponseInterface | null
return Psr\Http\Message\ResponseInterface | null

getResponseBodySummary() public static method

Will return null if the response is not printable.
public static getResponseBodySummary ( Psr\Http\Message\ResponseInterface $response ) : string | null
$response Psr\Http\Message\ResponseInterface
return string | null

hasResponse() public method

Check if a response was received
public hasResponse ( ) : boolean
return boolean

wrapException() public static method

Wrap non-RequestExceptions with a RequestException
public static wrapException ( Psr\Http\Message\RequestInterface $request, Exception $e ) : RequestException
$request Psr\Http\Message\RequestInterface
$e Exception
return RequestException