Skip to content

Commit

Permalink
Deployer::runJobs() shows better error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 1, 2016
1 parent 545e277 commit cab8167
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Deployment/Deployer.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,27 +384,27 @@ private function runJobs(array $jobs)
{
foreach ($jobs as $job) {
if (is_string($job) && preg_match('#^(https?|local|remote):\s*(.+)#', $job, $m)) {
$out = $err = NULL;
if ($m[1] === 'local') {
$out = @system($m[2], $code);
$err = $code !== 0;
$err = $code !== 0 ? "exit code $code" : NULL;
} elseif ($m[1] === 'remote') {
try {
$out = $this->server->execute($m[2]);
} catch (ServerException $e) {
$out = $e->getMessage();
$err = $e->getMessage() ?: 'unknown error';
}
$err = isset($e);
} else {
$out = Helpers::fetchUrl($job, $err);
}
$this->logger->log($job . ($out == NULL ? '' : ": $out")); // intentionally ==
if ($err) {
throw new \RuntimeException('Error in job');
throw new \RuntimeException('Job failed, ' . $err);
}

} elseif (is_callable($job)) {
if ($job($this->server, $this->logger, $this) === FALSE) {
throw new \RuntimeException('Error in job');
throw new \RuntimeException('Job failed');
}

} else {
Expand Down

0 comments on commit cab8167

Please sign in to comment.