first commit
This commit is contained in:
7
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php
vendored
Normal file
7
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
/**
|
||||
* Exception when an HTTP error occurs (4xx or 5xx error)
|
||||
*/
|
||||
class BadResponseException extends RequestException {}
|
||||
7
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php
vendored
Normal file
7
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
/**
|
||||
* Exception when a client error is encountered (4xx codes)
|
||||
*/
|
||||
class ClientException extends BadResponseException {}
|
||||
4
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php
vendored
Normal file
4
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
class ConnectException extends RequestException {}
|
||||
4
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/CouldNotRewindStreamException.php
vendored
Normal file
4
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/CouldNotRewindStreamException.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
class CouldNotRewindStreamException extends RequestException {}
|
||||
31
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/ParseException.php
vendored
Normal file
31
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/ParseException.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
use GuzzleHttp\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Exception when a client is unable to parse the response body as XML or JSON
|
||||
*/
|
||||
class ParseException extends TransferException
|
||||
{
|
||||
/** @var ResponseInterface */
|
||||
private $response;
|
||||
|
||||
public function __construct(
|
||||
$message = '',
|
||||
ResponseInterface $response = null,
|
||||
\Exception $previous = null
|
||||
) {
|
||||
parent::__construct($message, 0, $previous);
|
||||
$this->response = $response;
|
||||
}
|
||||
/**
|
||||
* Get the associated response
|
||||
*
|
||||
* @return ResponseInterface|null
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
}
|
||||
121
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php
vendored
Normal file
121
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
use GuzzleHttp\Message\RequestInterface;
|
||||
use GuzzleHttp\Message\ResponseInterface;
|
||||
use GuzzleHttp\Ring\Exception\ConnectException;
|
||||
use GuzzleHttp\Exception\ConnectException as HttpConnectException;
|
||||
use GuzzleHttp\Ring\Future\FutureInterface;
|
||||
|
||||
/**
|
||||
* HTTP Request exception
|
||||
*/
|
||||
class RequestException extends TransferException
|
||||
{
|
||||
/** @var RequestInterface */
|
||||
private $request;
|
||||
|
||||
/** @var ResponseInterface */
|
||||
private $response;
|
||||
|
||||
public function __construct(
|
||||
$message,
|
||||
RequestInterface $request,
|
||||
ResponseInterface $response = null,
|
||||
\Exception $previous = null
|
||||
) {
|
||||
// Set the code of the exception if the response is set and not future.
|
||||
$code = $response && !($response instanceof FutureInterface)
|
||||
? $response->getStatusCode()
|
||||
: 0;
|
||||
parent::__construct($message, $code, $previous);
|
||||
$this->request = $request;
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap non-RequestExceptions with a RequestException
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
* @param \Exception $e
|
||||
*
|
||||
* @return RequestException
|
||||
*/
|
||||
public static function wrapException(RequestInterface $request, \Exception $e)
|
||||
{
|
||||
if ($e instanceof RequestException) {
|
||||
return $e;
|
||||
} elseif ($e instanceof ConnectException) {
|
||||
return new HttpConnectException($e->getMessage(), $request, null, $e);
|
||||
} else {
|
||||
return new RequestException($e->getMessage(), $request, null, $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method to create a new exception with a normalized error message
|
||||
*
|
||||
* @param RequestInterface $request Request
|
||||
* @param ResponseInterface $response Response received
|
||||
* @param \Exception $previous Previous exception
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function create(
|
||||
RequestInterface $request,
|
||||
ResponseInterface $response = null,
|
||||
\Exception $previous = null
|
||||
) {
|
||||
if (!$response) {
|
||||
return new self('Error completing request', $request, null, $previous);
|
||||
}
|
||||
|
||||
$level = floor($response->getStatusCode() / 100);
|
||||
if ($level == '4') {
|
||||
$label = 'Client error response';
|
||||
$className = __NAMESPACE__ . '\\ClientException';
|
||||
} elseif ($level == '5') {
|
||||
$label = 'Server error response';
|
||||
$className = __NAMESPACE__ . '\\ServerException';
|
||||
} else {
|
||||
$label = 'Unsuccessful response';
|
||||
$className = __CLASS__;
|
||||
}
|
||||
|
||||
$message = $label . ' [url] ' . $request->getUrl()
|
||||
. ' [status code] ' . $response->getStatusCode()
|
||||
. ' [reason phrase] ' . $response->getReasonPhrase();
|
||||
|
||||
return new $className($message, $request, $response, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the request that caused the exception
|
||||
*
|
||||
* @return RequestInterface
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the associated response
|
||||
*
|
||||
* @return ResponseInterface|null
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a response was received
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasResponse()
|
||||
{
|
||||
return $this->response !== null;
|
||||
}
|
||||
}
|
||||
7
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php
vendored
Normal file
7
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
/**
|
||||
* Exception when a server error is encountered (5xx codes)
|
||||
*/
|
||||
class ServerException extends BadResponseException {}
|
||||
4
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/StateException.php
vendored
Normal file
4
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/StateException.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
class StateException extends TransferException {};
|
||||
4
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php
vendored
Normal file
4
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
class TooManyRedirectsException extends RequestException {}
|
||||
4
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php
vendored
Normal file
4
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
class TransferException extends \RuntimeException {}
|
||||
34
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/XmlParseException.php
vendored
Normal file
34
modules/ps_mbo/vendor/guzzlehttp/guzzle/src/Exception/XmlParseException.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
use GuzzleHttp\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Exception when a client is unable to parse the response body as XML
|
||||
*/
|
||||
class XmlParseException extends ParseException
|
||||
{
|
||||
/** @var \LibXMLError */
|
||||
protected $error;
|
||||
|
||||
public function __construct(
|
||||
$message = '',
|
||||
ResponseInterface $response = null,
|
||||
\Exception $previous = null,
|
||||
\LibXMLError $error = null
|
||||
) {
|
||||
parent::__construct($message, $response, $previous);
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the associated error
|
||||
*
|
||||
* @return \LibXMLError|null
|
||||
*/
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user