Skip to content

Commit

Permalink
use getTrace on exception when not using xdebug to avoid returning em…
Browse files Browse the repository at this point in the history
…pty array when a full stack trace is available
  • Loading branch information
SBLAdam committed Aug 22, 2017
1 parent 2cb6120 commit 0a23c5e
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions src/Whoops/Exception/Inspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,27 +194,16 @@ public function getFrames()
*/
protected function getTrace($e)
{
$traces = $e->getTrace();

// Get trace from xdebug if enabled, failure exceptions only trace to the shutdown handler by default
if (!$e instanceof \ErrorException) {
return $traces;
}

if (!Misc::isLevelFatal($e->getSeverity())) {
return $traces;
}
// Use xdebug to get the full stack trace and remove the shutdown handler stack trace
if (extension_loaded('xdebug') && xdebug_is_enabled()
&& $e instanceof \ErrorException && Misc::isLevelFatal($e->getSeverity())) {
$stack = array_reverse(xdebug_get_function_stack());
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);

if (!extension_loaded('xdebug') || !xdebug_is_enabled()) {
return [];
return array_diff_key($stack, $trace);
}

// Use xdebug to get the full stack trace and remove the shutdown handler stack trace
$stack = array_reverse(xdebug_get_function_stack());
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$traces = array_diff_key($stack, $trace);

return $traces;
return $e->getTrace();
}

/**
Expand Down

0 comments on commit 0a23c5e

Please sign in to comment.