]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Provide a hook for aborted workflow
authorvrana <jakubv@fb.com>
Tue, 16 Oct 2012 17:21:56 +0000 (10:21 -0700)
committervrana <jakubv@fb.com>
Mon, 22 Oct 2012 19:55:39 +0000 (12:55 -0700)
Summary:
We start Sandcastle push when `arc diff` starts.
If `arc diff` throws then HHVM waits for finishing the futures.
We need to kill them sooner.

Test Plan: Will implement the hook.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3713

scripts/arcanist.php
src/configuration/ArcanistConfiguration.php

index f6a41de3e2d3d1ebe47a9aae411cfba3d8ca8932..64938edee5db61c9104b314ee758943f1df144d0 100755 (executable)
@@ -319,25 +319,27 @@ try {
   $config->didRunWorkflow($command, $workflow, $err);
   exit((int)$err);
 
-} catch (ArcanistUsageException $ex) {
-  echo phutil_console_format(
-    "**Usage Exception:** %s\n",
-    $ex->getMessage());
-  if ($config_trace_mode) {
-    echo "\n";
-    throw $ex;
+} catch (Exception $ex) {
+  $is_usage = ($ex instanceof ArcanistUsageException);
+  if ($is_usage) {
+    echo phutil_console_format(
+      "**Usage Exception:** %s\n",
+      $ex->getMessage());
   }
 
-  exit(1);
-} catch (Exception $ex) {
+  $config->didAbortWorkflow($command, $workflow, $ex);
+
   if ($config_trace_mode) {
+    echo "\n";
     throw $ex;
   }
 
-  echo phutil_console_format(
-    "**Exception**\n%s\n%s\n",
-    $ex->getMessage(),
-    "(Run with --trace for a full exception trace.)");
+  if (!$is_usage) {
+    echo phutil_console_format(
+      "**Exception**\n%s\n%s\n",
+      $ex->getMessage(),
+      "(Run with --trace for a full exception trace.)");
+  }
 
   exit(1);
 }
index 696b8e775efc4c5b07fe1128926e4d7bf14992be..f8af6909b535e20475f6947b64bb171fca22af52 100644 (file)
@@ -29,7 +29,7 @@
  *    - create, replace, or disable workflows by overriding buildWorkflow()
  *      and buildAllWorkflows();
  *    - add additional steps before or after workflows run by overriding
- *      willRunWorkflow() or didRunWorkflow(); and
+ *      willRunWorkflow() or didRunWorkflow() or didAbortWorkflow(); and
  *    - add new flags to existing workflows by overriding
  *      getCustomArgumentsForCommand().
  *
@@ -93,6 +93,14 @@ class ArcanistConfiguration {
     // This is a hook.
   }
 
+  public function didAbortWorkflow(
+    $command,
+    ArcanistBaseWorkflow $workflow,
+    Exception $ex) {
+
+    // This is a hook.
+  }
+
   public function getCustomArgumentsForCommand($command) {
     return array();
   }