Currently, CommandExecutor.execute() returns the exit code of the executed command.
However, there are many cases in which we expect an internal tool to exit with a given (and possibly set of) exit codes.
CommandExecutor should provide a way, out of the box, to both execute and test the exit code, instead of leaving that logic to its callers.
One option is to add a method such as:
Anoter option is to use a property of a Command, but this might prevent the use case of several executions of the same Command expecting different exit codes across multiple executions.
In order to make it possible to more easily reuse the CommandException class, it should provide a constructor which does not take an inner exception as argument. The current workaround is to pass null as the inner exception argument.