/** * Runs a command and throws an exception if the run fails. * * @param ICommandExecutor $command The command to run. * @param string $exceptionMessage The message of the exception. * * @return \YapepBase\Shell\CommandOutput The output of the command. * * @throws \YapepBase\Exception\File\Exception If the command failed to run. */ protected function runCommandAndThrowExceptionIfFailed(ICommandExecutor $command, $exceptionMessage) { $result = $command->run(); if (!$result->isSuccessful()) { throw new Exception($exceptionMessage, 0, null, $result); } return $result; }