Skip to content

Commit 0c87981

Browse files
authored
Support Throwables
Fixes #497
1 parent 730375e commit 0c87981

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

src/LaravelDebugbar.php

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ function () use ($debugbar) {
182182
$this->app['events']->subscribe($eventCollector);
183183

184184
} catch (\Exception $e) {
185-
$this->addException(
185+
$this->addThrowable(
186186
new Exception(
187187
'Cannot add EventCollector to Laravel Debugbar: ' . $e->getMessage(),
188188
$e->getCode(),
@@ -203,7 +203,7 @@ function ($view) use ($debugbar) {
203203
}
204204
);
205205
} catch (\Exception $e) {
206-
$this->addException(
206+
$this->addThrowable(
207207
new Exception(
208208
'Cannot add ViewCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e
209209
)
@@ -215,7 +215,7 @@ function ($view) use ($debugbar) {
215215
try {
216216
$this->addCollector($this->app->make('Barryvdh\Debugbar\DataCollector\IlluminateRouteCollector'));
217217
} catch (\Exception $e) {
218-
$this->addException(
218+
$this->addThrowable(
219219
new Exception(
220220
'Cannot add RouteCollector to Laravel Debugbar: ' . $e->getMessage(),
221221
$e->getCode(),
@@ -253,7 +253,7 @@ function ($level, $message, $context) use ($logger) {
253253
$this->addCollector(new MonologCollector($this->app['log']->getMonolog()));
254254
}
255255
} catch (\Exception $e) {
256-
$this->addException(
256+
$this->addThrowable(
257257
new Exception(
258258
'Cannot add LogsCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e
259259
)
@@ -313,7 +313,7 @@ function ($query, $bindings = null, $time = null, $connectionName = null) use ($
313313
}
314314
);
315315
} catch (\Exception $e) {
316-
$this->addException(
316+
$this->addThrowable(
317317
new Exception(
318318
'Cannot add listen to Queries for Laravel Debugbar: ' . $e->getMessage(),
319319
$e->getCode(),
@@ -334,7 +334,7 @@ function ($query, $bindings = null, $time = null, $connectionName = null) use ($
334334
$this['messages']->aggregate(new SwiftLogCollector($mailer));
335335
}
336336
} catch (\Exception $e) {
337-
$this->addException(
337+
$this->addThrowable(
338338
new Exception(
339339
'Cannot add MailCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e
340340
)
@@ -347,7 +347,7 @@ function ($query, $bindings = null, $time = null, $connectionName = null) use ($
347347
$file = $this->app['config']->get('debugbar.options.logs.file');
348348
$this->addCollector(new LogsCollector($file));
349349
} catch (\Exception $e) {
350-
$this->addException(
350+
$this->addThrowable(
351351
new Exception(
352352
'Cannot add LogsCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e
353353
)
@@ -373,7 +373,7 @@ function ($query, $bindings = null, $time = null, $connectionName = null) use ($
373373
);
374374
$this->addCollector($authCollector);
375375
} catch (\Exception $e) {
376-
$this->addException(
376+
$this->addThrowable(
377377
new Exception(
378378
'Cannot add AuthCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e
379379
)
@@ -430,7 +430,7 @@ public function stopMeasure($name)
430430
try {
431431
$collector->stopMeasure($name);
432432
} catch (\Exception $e) {
433-
// $this->addException($e);
433+
// $this->addThrowable($e);
434434
}
435435
}
436436
}
@@ -439,13 +439,24 @@ public function stopMeasure($name)
439439
* Adds an exception to be profiled in the debug bar
440440
*
441441
* @param Exception $e
442+
* @deprecated in favor of addThrowable
442443
*/
443444
public function addException(Exception $e)
445+
{
446+
return $this->addThrowable($e);
447+
}
448+
449+
/**
450+
* Adds an exception to be profiled in the debug bar
451+
*
452+
* @param Exception $e
453+
*/
454+
public function addThrowable($e)
444455
{
445456
if ($this->hasCollector('exceptions')) {
446457
/** @var \DebugBar\DataCollector\ExceptionsCollector $collector */
447458
$collector = $this->getCollector('exceptions');
448-
$collector->addException($e);
459+
$collector->addThrowable($e);
449460
}
450461
}
451462

@@ -480,7 +491,7 @@ public function modifyResponse(Request $request, Response $response)
480491

481492
// Show the Http Response Exception in the Debugbar, when available
482493
if (isset($response->exception)) {
483-
$this->addException($response->exception);
494+
$this->addThrowable($response->exception);
484495
}
485496

486497
if ($this->shouldCollect('config', false)) {
@@ -489,7 +500,7 @@ public function modifyResponse(Request $request, Response $response)
489500
$configCollector->setData($app['config']->all());
490501
$this->addCollector($configCollector);
491502
} catch (\Exception $e) {
492-
$this->addException(
503+
$this->addThrowable(
493504
new Exception(
494505
'Cannot add ConfigCollector to Laravel Debugbar: ' . $e->getMessage(),
495506
$e->getCode(),
@@ -510,7 +521,7 @@ public function modifyResponse(Request $request, Response $response)
510521
try {
511522
$this->addCollector(new SessionCollector($sessionManager));
512523
} catch (\Exception $e) {
513-
$this->addException(
524+
$this->addThrowable(
514525
new Exception(
515526
'Cannot add SessionCollector to Laravel Debugbar: ' . $e->getMessage(),
516527
$e->getCode(),
@@ -527,7 +538,7 @@ public function modifyResponse(Request $request, Response $response)
527538
try {
528539
$this->addCollector(new SymfonyRequestCollector($request, $response, $sessionManager));
529540
} catch (\Exception $e) {
530-
$this->addException(
541+
$this->addThrowable(
531542
new Exception(
532543
'Cannot add SymfonyRequestCollector to Laravel Debugbar: ' . $e->getMessage(),
533544
$e->getCode(),
@@ -542,7 +553,7 @@ public function modifyResponse(Request $request, Response $response)
542553
try {
543554
$this->addCollector(new ClockworkCollector($request, $response, $sessionManager));
544555
} catch (\Exception $e) {
545-
$this->addException(
556+
$this->addThrowable(
546557
new Exception(
547558
'Cannot add ClockworkCollector to Laravel Debugbar: ' . $e->getMessage(),
548559
$e->getCode(),

0 commit comments

Comments
 (0)