2 namespace Consolidation\AnnotatedCommand;
5 * Return a CommandError as the result of a command to pass a status
6 * code and error message to be displayed.
8 * @package Consolidation\AnnotatedCommand
10 class CommandError implements ExitCodeInterface, OutputDataInterface
15 public function __construct($message = null, $exitCode = 1)
17 $this->message = $message;
18 // Ensure the exit code is non-zero. The exit code may have
19 // come from an exception, and those often default to zero if
20 // a specific value is not provided.
21 $this->exitCode = $exitCode == 0 ? 1 : $exitCode;
23 public function getExitCode()
25 return $this->exitCode;
28 public function getOutputData()
30 return $this->message;