Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/stacktrace is missing for haltable exceptions #524

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 18 additions & 18 deletions src/Whoops/Exception/Inspector.php
Expand Up @@ -189,32 +189,32 @@ public function getFrames()
*
* If xdebug is installed
*
* @param \Throwable $exception
* @param \Throwable $e
* @return array
*/
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 ($this->useXdebugForTrace($e)) {
$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 $e->getTrace();
}

return $traces;
/**
* Determine if we should use xdebug for our stack trace
*
* @param \Throwable $e
* @return bool
*/
protected function useXdebugForTrace($e)
{
return extension_loaded('xdebug') && xdebug_is_enabled()
&& $e instanceof \ErrorException && Misc::isLevelFatal($e->getSeverity());
}

/**
Expand Down