EasyPost\Requestor::handleApiError PHP Method

handleApiError() public method

public handleApiError ( string $httpBody, integer $httpStatus, array $response )
$httpBody string
$httpStatus integer
$response array
    public function handleApiError($httpBody, $httpStatus, $response)
    {
        if (!is_array($response) || !isset($response['error'])) {
            throw new Error("Invalid response object from API: HTTP Status: ({$httpStatus}) {$httpBody})", $httpStatus, $httpBody);
        }
        throw new Error(is_array($response['error']) ? $response['error']['message'] : (!empty($response['error']) ? $response['error'] : ""), $httpStatus, $httpBody);
    }