Skip to content

Commit

Permalink
use dedicated useXdebugForTrace method
Browse files Browse the repository at this point in the history
  • Loading branch information
SBLAdam committed Aug 22, 2017
1 parent ed7fc0a commit f4d733a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Whoops/Exception/Inspector.php
Expand Up @@ -195,8 +195,7 @@ public function getFrames()
protected function getTrace(\Throwable $e)
{
// 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()))) {
if ($this->useXdebugForTrace($e)) {
$stack = array_reverse(xdebug_get_function_stack());
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);

Expand All @@ -206,6 +205,18 @@ protected function getTrace(\Throwable $e)
return $e->getTrace();
}

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

/**
* Given an exception, generates an array in the format
* generated by Exception::getTrace()
Expand Down

0 comments on commit f4d733a

Please sign in to comment.