Return $result if getStdError() returns an empty string.

This is done to support applications which return a non-zero exit status but do not output error messages to stderr.
This commit is contained in:
Tom Rochette 2015-03-04 15:22:45 -05:00
parent bb330efba0
commit b45e2dc0f9

View File

@ -74,12 +74,12 @@ class PhpSecLib implements ServerInterface
break;
case Configuration::AUTH_BY_AGENT:
$key = new Agent();
$result = $this->sftp->login($serverConfig->getUser(), $key);
break;
default:
throw new RuntimeException('You need to specify authentication method.');
}
@ -109,7 +109,8 @@ class PhpSecLib implements ServerInterface
$result = $this->sftp->exec($command);
if ($this->sftp->getExitStatus() !== 0) {
throw new \RuntimeException($this->sftp->getStdError());
$output = $this->sftp->getStdError() ?: $result;
throw new \RuntimeException($output);
}
return $result;