@@ -25,15 +25,23 @@ class ExceptionsCollector extends DataCollector implements Renderable
2525 * Adds an exception to be profiled in the debug bar
2626 *
2727 * @param Exception $e
28+ * @deprecated in favor on addThrowable
2829 */
2930 public function addException (Exception $ e )
31+ {
32+ $ this ->addThrowable ($ e );
33+ }
34+
35+ /**
36+ * Adds a Throwable to be profiled in the debug bar
37+ *
38+ * @param \Throwable $e
39+ */
40+ public function addThrowable ($ e )
3041 {
3142 $ this ->exceptions [] = $ e ;
3243 if ($ this ->chainExceptions && $ previous = $ e ->getPrevious ()) {
33- if (!$ previous instanceof Exception) {
34- $ previous = new FatalThrowableError ($ previous );
35- }
36- $ this ->addException ($ previous );
44+ $ this ->addThrowable ($ previous );
3745 }
3846 }
3947
@@ -50,7 +58,7 @@ public function setChainExceptions($chainExceptions = true)
5058 /**
5159 * Returns the list of exceptions being profiled
5260 *
53- * @return array[Exception ]
61+ * @return array[\Throwable ]
5462 */
5563 public function getExceptions ()
5664 {
@@ -61,7 +69,7 @@ public function collect()
6169 {
6270 return array (
6371 'count ' => count ($ this ->exceptions ),
64- 'exceptions ' => array_map (array ($ this , 'formatExceptionData ' ), $ this ->exceptions )
72+ 'exceptions ' => array_map (array ($ this , 'formatThrowableData ' ), $ this ->exceptions )
6573 );
6674 }
6775
@@ -70,8 +78,20 @@ public function collect()
7078 *
7179 * @param Exception $e
7280 * @return array
81+ * @deprecated in favor on formatThrowableData
7382 */
7483 public function formatExceptionData (Exception $ e )
84+ {
85+ return $ this ->formatThrowableData ($ e );
86+ }
87+
88+ /**
89+ * Returns Throwable data as an array
90+ *
91+ * @param \Throwable $e
92+ * @return array
93+ */
94+ public function formatThrowableData ($ e )
7595 {
7696 $ filePath = $ e ->getFile ();
7797 if ($ filePath && file_exists ($ filePath )) {
0 commit comments