]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Catch exceptions in didRunLinters()
authorvrana <jakubv@fb.com>
Tue, 26 Feb 2013 19:35:58 +0000 (11:35 -0800)
committervrana <jakubv@fb.com>
Tue, 26 Feb 2013 23:00:58 +0000 (15:00 -0800)
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

index f9cae8afc636ce10faedaac39cecb1bd112c8ed5..f3bb44bdd37009969ff7f24e590cd6df0be0fdd7 100644 (file)
@@ -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) {