Skip to content

Commit a1dfcd5

Browse files
committed
Added link in exception message
1 parent d593107 commit a1dfcd5

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/ClassDiscovery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected static function findOneByType($type)
7171
}
7272
}
7373

74-
throw new DiscoveryFailedException('Could not find resource using any discovery strategy', $exceptions);
74+
throw DiscoveryFailedException::create($exceptions);
7575
}
7676

7777
/**

src/Exception/DiscoveryFailedException.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
final class DiscoveryFailedException extends \Exception implements Exception
1313
{
1414
/**
15-
* @var array
15+
* @var \Exception[]
1616
*/
1717
private $exceptions;
1818

1919
/**
20-
* @param $exceptions
20+
*
21+
* @param string $message
22+
* @param \Exception[] $exceptions
2123
*/
2224
public function __construct($message, array $exceptions = [])
2325
{
@@ -27,7 +29,21 @@ public function __construct($message, array $exceptions = [])
2729
}
2830

2931
/**
30-
* @return array
32+
* @param \Exception[] $exceptions
33+
*/
34+
public static function create($exceptions)
35+
{
36+
$message = 'Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors';
37+
foreach ($exceptions as $e) {
38+
$message .= "\n - ".$e->getMessage();
39+
}
40+
$message.="\n\n";
41+
42+
return new self($message, $exceptions);
43+
}
44+
45+
/**
46+
* @return \Exception[]
3147
*/
3248
public function getExceptions()
3349
{

0 commit comments

Comments
 (0)