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 55
66### Changed
77
8+ - Made exception messages clearer. ` StrategyUnavailableException ` is no longer the previous exception to ` DiscoveryFailedException ` .
89- ` CommonClassesStrategy ` is using ` self ` instead of ` static ` . Using ` static ` makes no sense when ` CommonClassesStrategy ` is final.
910
1011## 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)
7171 }
7272 }
7373
74- throw new DiscoveryFailedException ( ' Could not find resource using any discovery strategy ' , $ exceptions );
74+ throw DiscoveryFailedException:: create ( $ exceptions );
7575 }
7676
7777 /**
Original file line number Diff line number Diff line change 1212final class DiscoveryFailedException extends \Exception implements Exception
1313{
1414 /**
15- * @var array
15+ * @var \Exception[]
1616 */
1717 private $ exceptions ;
1818
1919 /**
20- * @param $exceptions
20+ * @param string $message
21+ * @param \Exception[] $exceptions
2122 */
2223 public function __construct ($ message , array $ exceptions = [])
2324 {
2425 $ this ->exceptions = $ exceptions ;
2526
26- parent ::__construct ($ message, 0 , array_shift ( $ exceptions ) );
27+ parent ::__construct ($ message );
2728 }
2829
2930 /**
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[]
3146 */
3247 public function getExceptions ()
3348 {
You can’t perform that action at this time.
0 commit comments