File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 5
5
6
6
### Changed
7
7
8
+ - Made exception messages clearer. ` StrategyUnavailableException ` is no longer the previous exception to ` DiscoveryFailedException ` .
8
9
- ` CommonClassesStrategy ` is using ` self ` instead of ` static ` . Using ` static ` makes no sense when ` CommonClassesStrategy ` is final.
9
10
10
11
## 1.1.0 - 2016-10-20
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ protected static function findOneByType($type)
71
71
}
72
72
}
73
73
74
- throw new DiscoveryFailedException ( ' Could not find resource using any discovery strategy ' , $ exceptions );
74
+ throw DiscoveryFailedException:: create ( $ exceptions );
75
75
}
76
76
77
77
/**
Original file line number Diff line number Diff line change 12
12
final class DiscoveryFailedException extends \Exception implements Exception
13
13
{
14
14
/**
15
- * @var array
15
+ * @var \Exception[]
16
16
*/
17
17
private $ exceptions ;
18
18
19
19
/**
20
- * @param $exceptions
20
+ * @param string $message
21
+ * @param \Exception[] $exceptions
21
22
*/
22
23
public function __construct ($ message , array $ exceptions = [])
23
24
{
24
25
$ this ->exceptions = $ exceptions ;
25
26
26
- parent ::__construct ($ message, 0 , array_shift ( $ exceptions ) );
27
+ parent ::__construct ($ message );
27
28
}
28
29
29
30
/**
30
- * @return array
31
+ * @param \Exception[] $exceptions
32
+ */
33
+ public static function create ($ exceptions )
34
+ {
35
+ $ message = 'Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors ' ;
36
+ foreach ($ exceptions as $ e ) {
37
+ $ message .= "\n - " .$ e ->getMessage ();
38
+ }
39
+ $ message .= "\n\n" ;
40
+
41
+ return new self ($ message , $ exceptions );
42
+ }
43
+
44
+ /**
45
+ * @return \Exception[]
31
46
*/
32
47
public function getExceptions ()
33
48
{
You can’t perform that action at this time.
0 commit comments