Skip to content

Commit

Permalink
Pass build object to SystemCommandException
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Dec 5, 2015
1 parent 4990f78 commit 3848399
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
11 changes: 10 additions & 1 deletion src/PhpBrew/Exception/SystemCommandException.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
<?php
namespace PhpBrew\Exception;
use RuntimeException;
use PhpBrew\Build;

class SystemCommandException extends RuntimeException
{
protected $logFile;

public function __construct($message, $logFile = null)
protected $build;

public function __construct($message, Build $build = null, $logFile = null)
{
parent::__construct($message);
$this->build = $build;
$this->logFile = $logFile;
}

public function getLogFile()
{
return $this->logFile;
}

public function getBuild()
{
return $this->build;
}
}


Expand Down
2 changes: 1 addition & 1 deletion src/PhpBrew/Tasks/BuildTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function run(Build $build, $targets = array())
$startTime = microtime(true);
$code = $cmd->execute();
if ($code != 0) {
throw new SystemCommandException('Make failed.', $build->getBuildLogPath());
throw new SystemCommandException('Make failed.', $build, $build->getBuildLogPath());
}
$buildTime = round((microtime(true) - $startTime) / 60, 1);
$this->info("Build finished: $buildTime minutes.");
Expand Down
4 changes: 2 additions & 2 deletions src/PhpBrew/Tasks/ConfigureTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function run(Build $build, $variantOptions)
$this->debug("configure file not found, running './buildconf --force'...");
$lastline = system('./buildconf --force', $status);
if ($status !== 0) {
throw new SystemCommandException("buildconf error: $lastline");
throw new SystemCommandException("buildconf error: $lastline", $build);
}
}
$prefix = $build->getInstallPrefix();
Expand Down Expand Up @@ -123,7 +123,7 @@ public function run(Build $build, $variantOptions)
if (!$this->options->dryrun) {
$code = $cmd->execute();
if ($code != 0) {
throw new SystemCommandException("Configure failed: $code", $buildLogPath);
throw new SystemCommandException("Configure failed: $code", $build, $buildLogPath);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/PhpBrew/Tasks/InstallTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function install(Build $build)
if (!$this->options->dryrun) {
$code = $cmd->execute();
if ($code != 0) {
throw new SystemCommandException('Install failed.', $build->getBuildLogPath());
throw new SystemCommandException('Install failed.', $build, $build->getBuildLogPath());
}
}
$build->setState(Build::STATE_INSTALL);
Expand Down

0 comments on commit 3848399

Please sign in to comment.