Skip to content

Commit

Permalink
Verbosity of exceptions during analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
Halleck45 committed Feb 16, 2015
1 parent 4e1b60e commit f351a97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/Hal/Application/Command/Job/DoAnalyze.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,18 @@ public function execute(ResultCollection $collection, ResultCollection $aggregat
}

// Analyze
$resultSet = $fileAnalyzer->execute($filename);
try {
$resultSet = $fileAnalyzer->execute($filename);
} catch(\Exception $e) {
throw new \Exception(
(
sprintf("a '%s' exception occured analyzing file %s\nMessage: %s", get_class($e), $filename, $e->getMessage())
. sprintf("\n------------\nStack:\n%s", $e->getTraceAsString())
. sprintf("\n------------\nDo not hesitate to report a bug: https://github.com/Halleck45/PhpMetrics/issues")
)
, 0, $e->getPrevious());
}

$collection->push($resultSet);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Hal/Component/OOP/Extractor/MethodExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function extract(&$n, TokenCollection $tokens)
{
$declaration = $this->searcher->getUnder(array(')'), $n, $tokens);
if(!preg_match('!function\s+(.*)\(\s*(.*)!is', $declaration, $matches)) {
throw new \Exception('Closure detected instead of method');
throw new \Exception(sprintf("Closure detected instead of method\nDetails:\n%s", $declaration));
}
list(, $name, $args) = $matches;
$method = new ReflectedMethod($name);
Expand Down

0 comments on commit f351a97

Please sign in to comment.