Skip to content

Commit

Permalink
Support Throwables
Browse files Browse the repository at this point in the history
Fixes #497
  • Loading branch information
barryvdh authored Sep 15, 2016
1 parent 730375e commit 0c87981
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions src/LaravelDebugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function () use ($debugbar) {
$this->app['events']->subscribe($eventCollector);

} catch (\Exception $e) {
$this->addException(
$this->addThrowable(
new Exception(
'Cannot add EventCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
Expand All @@ -203,7 +203,7 @@ function ($view) use ($debugbar) {
}
);
} catch (\Exception $e) {
$this->addException(
$this->addThrowable(
new Exception(
'Cannot add ViewCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e
)
Expand All @@ -215,7 +215,7 @@ function ($view) use ($debugbar) {
try {
$this->addCollector($this->app->make('Barryvdh\Debugbar\DataCollector\IlluminateRouteCollector'));
} catch (\Exception $e) {
$this->addException(
$this->addThrowable(
new Exception(
'Cannot add RouteCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
Expand Down Expand Up @@ -253,7 +253,7 @@ function ($level, $message, $context) use ($logger) {
$this->addCollector(new MonologCollector($this->app['log']->getMonolog()));
}
} catch (\Exception $e) {
$this->addException(
$this->addThrowable(
new Exception(
'Cannot add LogsCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e
)
Expand Down Expand Up @@ -313,7 +313,7 @@ function ($query, $bindings = null, $time = null, $connectionName = null) use ($
}
);
} catch (\Exception $e) {
$this->addException(
$this->addThrowable(
new Exception(
'Cannot add listen to Queries for Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
Expand All @@ -334,7 +334,7 @@ function ($query, $bindings = null, $time = null, $connectionName = null) use ($
$this['messages']->aggregate(new SwiftLogCollector($mailer));
}
} catch (\Exception $e) {
$this->addException(
$this->addThrowable(
new Exception(
'Cannot add MailCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e
)
Expand All @@ -347,7 +347,7 @@ function ($query, $bindings = null, $time = null, $connectionName = null) use ($
$file = $this->app['config']->get('debugbar.options.logs.file');
$this->addCollector(new LogsCollector($file));
} catch (\Exception $e) {
$this->addException(
$this->addThrowable(
new Exception(
'Cannot add LogsCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e
)
Expand All @@ -373,7 +373,7 @@ function ($query, $bindings = null, $time = null, $connectionName = null) use ($
);
$this->addCollector($authCollector);
} catch (\Exception $e) {
$this->addException(
$this->addThrowable(
new Exception(
'Cannot add AuthCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e
)
Expand Down Expand Up @@ -430,7 +430,7 @@ public function stopMeasure($name)
try {
$collector->stopMeasure($name);
} catch (\Exception $e) {
// $this->addException($e);
// $this->addThrowable($e);
}
}
}
Expand All @@ -439,13 +439,24 @@ public function stopMeasure($name)
* Adds an exception to be profiled in the debug bar
*
* @param Exception $e
* @deprecated in favor of addThrowable
*/
public function addException(Exception $e)
{
return $this->addThrowable($e);
}

/**
* Adds an exception to be profiled in the debug bar
*
* @param Exception $e
*/
public function addThrowable($e)
{
if ($this->hasCollector('exceptions')) {
/** @var \DebugBar\DataCollector\ExceptionsCollector $collector */
$collector = $this->getCollector('exceptions');
$collector->addException($e);
$collector->addThrowable($e);
}
}

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

// Show the Http Response Exception in the Debugbar, when available
if (isset($response->exception)) {
$this->addException($response->exception);
$this->addThrowable($response->exception);
}

if ($this->shouldCollect('config', false)) {
Expand All @@ -489,7 +500,7 @@ public function modifyResponse(Request $request, Response $response)
$configCollector->setData($app['config']->all());
$this->addCollector($configCollector);
} catch (\Exception $e) {
$this->addException(
$this->addThrowable(
new Exception(
'Cannot add ConfigCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
Expand All @@ -510,7 +521,7 @@ public function modifyResponse(Request $request, Response $response)
try {
$this->addCollector(new SessionCollector($sessionManager));
} catch (\Exception $e) {
$this->addException(
$this->addThrowable(
new Exception(
'Cannot add SessionCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
Expand All @@ -527,7 +538,7 @@ public function modifyResponse(Request $request, Response $response)
try {
$this->addCollector(new SymfonyRequestCollector($request, $response, $sessionManager));
} catch (\Exception $e) {
$this->addException(
$this->addThrowable(
new Exception(
'Cannot add SymfonyRequestCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
Expand All @@ -542,7 +553,7 @@ public function modifyResponse(Request $request, Response $response)
try {
$this->addCollector(new ClockworkCollector($request, $response, $sessionManager));
} catch (\Exception $e) {
$this->addException(
$this->addThrowable(
new Exception(
'Cannot add ClockworkCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
Expand Down

0 comments on commit 0c87981

Please sign in to comment.