+ /**
+ * Set a mode to make the annotated command library re-throw
+ * any exception that it catches while processing a command.
+ *
+ * The default behavior in the current (2.x) branch is to catch
+ * the exception and replace it with a CommandError object that
+ * may be processed by the normal output processing passthrough.
+ *
+ * In the 3.x branch, exceptions will never be caught; they will
+ * be passed through, as if setPassExceptions(true) were called.
+ * This is the recommended behavior.
+ */
+ public function setPassExceptions($passExceptions)
+ {
+ $this->passExceptions = $passExceptions;
+ return $this;
+ }
+
+ public function commandErrorForException(\Exception $e)
+ {
+ if ($this->passExceptions) {
+ throw $e;
+ }
+ return new CommandError($e->getMessage(), $e->getCode());
+ }
+