APIResponseException

Extends \Exception Implements \NextEvent\PHPSDK\Util\Log\LogContextInterface

Generic Exception encapsulating an API error response

Thrown when a request to the NextEvent API failed with an error response. The exception provides extensive information about the request sent, the response received and the reasons which it didn't succeed.

Use the toLogContext() or dumpAsString() methods for logging.

package

NextEvent\PHPSDK\Exception

Methods

Exception constructor

__construct(string|\Exception $message, integer $code, \Exception $ex = null) 

Arguments

$message

string|\Exception

Error message or source exception

$code

integer

Error code

$ex

\Exception

Previous exception

Produces a string representation of this object

__toString() : string

Response

string

Returns a full string representation of this exception

dumpAsString(boolean $withStackTrace = false) : string

Including HTTP request, response and stack trace (optional)

Arguments

$withStackTrace

boolean

Append stack trace to output

Response

string

Get the error description provided by the API

getDescription() : string

Response

string

Get the sent HTTP request message

getRequest() : \GuzzleHttp\Psr7\Request

Response

\GuzzleHttp\Psr7\Request

Get the unique identifier of the API request

getRequestID() : string

Use this in support inquiries to let us track the request in our logs

Response

string

Get the received HTTP response message

getResponse() : \GuzzleHttp\Psr7\Response

Response

\GuzzleHttp\Psr7\Response

Get HTTP response status code

getStatusCode() : integer|null|string

Response

integer|null|string

For convenience provide function to convert Exception to Context for logs

toLogContext() : array

Response

array