diff --git a/application/clicommands/ProcessCommand.php b/application/clicommands/ProcessCommand.php index 7b6fb4e..6a0158a 100644 --- a/application/clicommands/ProcessCommand.php +++ b/application/clicommands/ProcessCommand.php @@ -2,6 +2,8 @@ namespace Icinga\Module\Businessprocess\Clicommands; +use Exception; +use Icinga\Application\Logger; use Icinga\Cli\Command; use Icinga\Module\Businessprocess\BpConfig; use Icinga\Module\Businessprocess\BpNode; @@ -116,14 +118,17 @@ class ProcessCommand extends Command } /** @var BpNode $node */ - $node = $bp->getNode($this->params->shift()); - MonitoringState::apply($bp); - if ($bp->hasErrors()) { - printf( - "Checking Business Process %s failed: %s\n", - $node->getAlias(), - implode("\n", $bp->getErrors()) - ); + try { + $node = $bp->getNode($this->params->shift()); + MonitoringState::apply($bp); + if ($bp->hasErrors()) { + Logger::error("Checking Business Process %s failed: %s\n"); + + exit(3); + } + } catch (Exception $err) { + Logger::error("Checking Business Process failed: " . $err->getMessage()); + exit(3); }