diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:38:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:38:42 +0000 |
commit | c3ca98e1b35123f226c7f4c596b5dee78caa4223 (patch) | |
tree | 9b6eb109283da55e7d9064baa9fac795a40264cb /vendor/react/http/src/Message/ResponseException.php | |
parent | Initial commit. (diff) | |
download | icinga-php-thirdparty-upstream.tar.xz icinga-php-thirdparty-upstream.zip |
Adding upstream version 0.11.0.upstream/0.11.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/react/http/src/Message/ResponseException.php')
-rw-r--r-- | vendor/react/http/src/Message/ResponseException.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/vendor/react/http/src/Message/ResponseException.php b/vendor/react/http/src/Message/ResponseException.php new file mode 100644 index 0000000..f4912c9 --- /dev/null +++ b/vendor/react/http/src/Message/ResponseException.php @@ -0,0 +1,43 @@ +<?php + +namespace React\Http\Message; + +use RuntimeException; +use Psr\Http\Message\ResponseInterface; + +/** + * The `React\Http\Message\ResponseException` is an `Exception` sub-class that will be used to reject + * a request promise if the remote server returns a non-success status code + * (anything but 2xx or 3xx). + * You can control this behavior via the [`withRejectErrorResponse()` method](#withrejecterrorresponse). + * + * The `getCode(): int` method can be used to + * return the HTTP response status code. + */ +final class ResponseException extends RuntimeException +{ + private $response; + + public function __construct(ResponseInterface $response, $message = null, $code = null, $previous = null) + { + if ($message === null) { + $message = 'HTTP status code ' . $response->getStatusCode() . ' (' . $response->getReasonPhrase() . ')'; + } + if ($code === null) { + $code = $response->getStatusCode(); + } + parent::__construct($message, $code, $previous); + + $this->response = $response; + } + + /** + * Access its underlying response object. + * + * @return ResponseInterface + */ + public function getResponse() + { + return $this->response; + } +} |