Skip to content

Commit

Permalink
Optionally return filtered stacktrace as array.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Nov 5, 2006
1 parent 088b054 commit 1a970b2
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions PHPUnit/Util/Filter.php
Expand Up @@ -170,22 +170,31 @@ public static function getFilteredCodeCoverage(Array $codeCoverageInformation, $
* @param Exception $e
* @param boolean $filterTests
* @param boolean $filterPHPUnit
* @param boolean $asString
* @return string
* @access public
* @static
*/
public static function getFilteredStacktrace(Exception $e, $filterTests = TRUE, $filterPHPUnit = TRUE)
public static function getFilteredStacktrace(Exception $e, $filterTests = TRUE, $filterPHPUnit = TRUE, $asString = TRUE)
{
$filteredStacktrace = '';
if ($asString === TRUE) {
$filteredStacktrace = '';
} else {
$filteredStacktrace = array();
}

foreach ($e->getTrace() as $frame) {
if (!self::$filter || (isset($frame['file']) && !self::isFiltered($frame['file'], $filterTests, $filterPHPUnit))) {
$filteredStacktrace .= sprintf(
"%s:%s\n",
if ($asString === TRUE) {
$filteredStacktrace .= sprintf(
"%s:%s\n",

$frame['file'],
isset($frame['line']) ? $frame['line'] : '?'
);
$frame['file'],
isset($frame['line']) ? $frame['line'] : '?'
);
} else {
$filteredStacktrace[] = $frame;
}
}
}

Expand Down

0 comments on commit 1a970b2

Please sign in to comment.