From 266a4f4c752d7ad2834409cc9b1be5d107afd57e Mon Sep 17 00:00:00 2001 From: vrana Date: Tue, 26 Feb 2013 11:35:58 -0800 Subject: [PATCH] Catch exceptions in didRunLinters() Test Plan: Threw in `didRunLinters()` of one linter, still saw the result of other linters and "Some linters failed" at the end. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D5124 --- src/lint/engine/ArcanistLintEngine.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/lint/engine/ArcanistLintEngine.php b/src/lint/engine/ArcanistLintEngine.php index f9cae8af..f3bb44bd 100644 --- a/src/lint/engine/ArcanistLintEngine.php +++ b/src/lint/engine/ArcanistLintEngine.php @@ -232,7 +232,7 @@ abstract class ArcanistLintEngine { $profiler = PhutilServiceProfiler::getInstance(); $call_id = $profiler->beginServiceCall(array( 'type' => 'lint', - 'linter' => get_class($linter), + 'linter' => $linter_name, 'paths' => $paths, )); @@ -257,7 +257,7 @@ abstract class ArcanistLintEngine { } } - $this->didRunLinters($linters); + $exceptions += $this->didRunLinters($linters); foreach ($linters as $linter) { foreach ($linter->getLintMessages() as $message) { @@ -358,15 +358,28 @@ abstract class ArcanistLintEngine { protected function didRunLinters(array $linters) { assert_instances_of($linters, 'ArcanistLinter'); + $exceptions = array(); $profiler = PhutilServiceProfiler::getInstance(); - foreach ($linters as $linter) { + + foreach ($linters as $linter_name => $linter) { + if (!is_string($linter_name)) { + $linter_name = get_class($linter); + } + $call_id = $profiler->beginServiceCall(array( 'type' => 'lint', - 'linter' => get_class($linter), + 'linter' => $linter_name, )); - $linter->didRunLinters(); + + try { + $linter->didRunLinters(); + } catch (Exception $ex) { + $exceptions[$linter_name] = $ex; + } $profiler->endServiceCall($call_id, array()); } + + return $exceptions; } public function setRepositoryVersion($version) { -- 2.43.0