Skip to content

Commit

Permalink
Added ProcessException
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Słomka authored and Krzysztof Słomka committed Jul 12, 2017
1 parent 878e0c3 commit 3b154cb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Exception/ProcessException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Phobetor\RabbitMqSupervisorBundle\Exception;

use Symfony\Component\Process\Process;

class ProcessException extends \RuntimeException
{
/**
* ProcessException constructor.
*
* @param Process $process
*/
public function __construct(Process $process)
{
parent::__construct($process->getExitCodeText(), $process->getExitCode());
}
}
8 changes: 8 additions & 0 deletions Services/Supervisor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Phobetor\RabbitMqSupervisorBundle\Services;

use Phobetor\RabbitMqSupervisorBundle\Exception\ProcessException;
use Symfony\Component\Process\Process;

class Supervisor
Expand Down Expand Up @@ -35,6 +36,10 @@ public function execute($cmd)
$p->setWorkingDirectory($this->applicationDirectory);
$p->run();
$p->wait();
if ($p->getExitCode() !== 0) {
throw new ProcessException($p);
}

return $p;
}

Expand Down Expand Up @@ -63,6 +68,9 @@ public function run()
);
$p->setWorkingDirectory($this->applicationDirectory);
$p->run();
if ($p->getExitCode() !== 0) {
throw new ProcessException($p);
}
}
}
}

0 comments on commit 3b154cb

Please sign in to comment.