getError() public method

public getError ( boolean $trim = true ) : string
$trim boolean whether to `trim()` the return value. The default is `true`.
return string the error message, either stderr or internal message. Empty if none.
 /**
  * Displays application version from git describe and writes it to `version`
  */
 public function actionVersion($alias = '@app/version')
 {
     echo "Application Version\n";
     $cmd = new Command("git describe --dirty");
     if ($cmd->execute()) {
         echo $cmd->getOutput();
         file_put_contents(\Yii::getAlias($alias), $cmd->getOutput());
     } else {
         echo $cmd->getOutput();
         echo $cmd->getStdErr();
         echo $cmd->getError();
     }
     echo "\n";
 }
 /**
  * Generate application and required vendor documentation
  */
 public function actionGenerateDocs()
 {
     if ($this->confirm('Regenerate documentation files into ./docs-html', true)) {
         // array with commands
         $commands[] = 'vendor/bin/apidoc guide --interactive=0 docs web/apidocs';
         $commands[] = 'vendor/bin/apidoc api --interactive=0 --exclude=runtime/,tests/,vendor/ . web/apidocs';
         $commands[] = 'vendor/bin/apidoc guide --interactive=0 docs web/apidocs';
         foreach ($commands as $command) {
             $cmd = new Command($command);
             if ($cmd->execute()) {
                 echo $cmd->getOutput();
             } else {
                 echo $cmd->getOutput();
                 echo $cmd->getStdErr();
                 echo $cmd->getError();
             }
         }
     }
 }
示例#3
0
 /**
  * @param $cmd
  *
  * @return mixed
  * @throws Exception
  */
 private function execute($cmd)
 {
     $command = new Command();
     $command->setCommand($cmd);
     if ($command->execute()) {
         return $command->getOutput();
     } else {
         throw new Exception($command->getError());
     }
 }
 /**
  * Execute docker-compose commande
  * @codeCoverageIgnore
  * @param Command $command The command to execute.
  */
 protected function execute($command)
 {
     if ($command->execute()) {
         $output = $command->getOutput();
     } else {
         $output = $command->getError();
     }
     return array('output' => $output, 'code' => $command->getExitCode());
 }
 public function testCanNotRunInvalidCommandWithExec()
 {
     $command = new Command('ls --this-does-not-exist');
     $command->useExec = true;
     $this->assertFalse($command->getExecuted());
     $this->assertFalse($command->execute());
     $this->assertFalse($command->getExecuted());
     $this->assertNotEmpty($command->getError());
     $this->assertNotEmpty($command->getStdErr());
     $this->assertNotEmpty($command->getOutput());
     $this->assertEquals(2, $command->getExitCode());
 }