projects
/
m6w6
/
seekat
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
ws/style/uses/docs
[m6w6/seekat]
/
lib
/
Exception
/
RequestException.php
diff --git
a/lib/Exception/RequestException.php
b/lib/Exception/RequestException.php
index 877664e13ea458f17ed18ed639c2a4360f9d7c5b..a9da6d6c731bc8ed60d8ab011e04d66feb472a19 100644
(file)
--- a/
lib/Exception/RequestException.php
+++ b/
lib/Exception/RequestException.php
@@
-2,16
+2,30
@@
namespace seekat\Exception;
namespace seekat\Exception;
+use Exception as BaseException;
+use http\ {
+ Client\Response,
+ Header
+};
use seekat\Exception;
use seekat\Exception;
-use http\Header;
-use http\Client\Response;
-
-class RequestException extends \Exception implements Exception
+class RequestException extends BaseException implements Exception
{
{
+ /**
+ * JSON errors
+ * @var array
+ */
private $errors = [];
private $errors = [];
+
+ /**
+ * The response of the request which caused the exception
+ * @var Response
+ */
private $response;
private $response;
+ /**
+ * @param Response $response
+ */
function __construct(Response $response) {
$this->response = $response;
function __construct(Response $response) {
$this->response = $response;
@@
-36,10
+50,19
@@
class RequestException extends \Exception implements Exception
parent::__construct($message, $response->getResponseCode(), null);
}
parent::__construct($message, $response->getResponseCode(), null);
}
+ /**
+ * Get JSON errors
+ * @return array
+ */
function getErrors() : array {
return $this->errors;
}
function getErrors() : array {
return $this->errors;
}
+ /**
+ * Combine any errors into a single string
+ * @staticvar array $reasons
+ * @return string
+ */
function getErrorsAsString() {
static $reasons = [
"missing" => "The resource %1\$s does not exist\n",
function getErrorsAsString() {
static $reasons = [
"missing" => "The resource %1\$s does not exist\n",
@@
-63,6
+86,9
@@
class RequestException extends \Exception implements Exception
return $errors;
}
return $errors;
}
+ /**
+ * @return string
+ */
function __toString() : string {
return parent::__toString() . "\n". $this->getErrorsAsString();
}
function __toString() : string {
return parent::__toString() . "\n". $this->getErrorsAsString();
}