Skip to content

Commit 7c62c30

Browse files
authored
Add Throwables, deprecate exceptions (php-debugbar#281)
* Add addThrowable * Update composer.json
1 parent 13fed31 commit 7c62c30

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
"require": {
2020
"php": ">=5.3.0",
2121
"psr/log": "^1.0",
22-
"symfony/var-dumper": "^2.6|^3.0",
23-
"symfony/debug": "^2.6|^3.0"
22+
"symfony/var-dumper": "^2.6|^3.0"
2423
},
2524
"require-dev": {
2625
"phpunit/phpunit": "^4.0|^5.0"

src/DebugBar/DataCollector/ExceptionsCollector.php

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)