summaryrefslogtreecommitdiff
path: root/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php')
-rw-r--r--vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php b/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php
new file mode 100644
index 000000000..304b7276e
--- /dev/null
+++ b/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace Http\Discovery\Exception;
+
+use Http\Discovery\Exception;
+
+/**
+ * Thrown when all discovery strategies fails to find a resource.
+ *
+ * @author Tobias Nyholm <[email protected]>
+ */
+final class DiscoveryFailedException extends \Exception implements Exception
+{
+ /**
+ * @var \Exception[]
+ */
+ private $exceptions;
+
+ /**
+ * @param string $message
+ * @param \Exception[] $exceptions
+ */
+ public function __construct($message, array $exceptions = [])
+ {
+ $this->exceptions = $exceptions;
+
+ parent::__construct($message);
+ }
+
+ /**
+ * @param \Exception[] $exceptions
+ */
+ public static function create($exceptions)
+ {
+ $message = 'Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors';
+ foreach ($exceptions as $e) {
+ $message .= "\n - ".$e->getMessage();
+ }
+ $message .= "\n\n";
+
+ return new self($message, $exceptions);
+ }
+
+ /**
+ * @return \Exception[]
+ */
+ public function getExceptions()
+ {
+ return $this->exceptions;
+ }
+}