mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
CommandTransport: Return result in method send()
This commit is contained in:
parent
82e86b3c14
commit
3657a820fc
2 changed files with 9 additions and 7 deletions
|
|
@ -249,14 +249,16 @@ class ApiCommandTransport implements CommandTransportInterface
|
|||
return;
|
||||
}
|
||||
|
||||
$result = array_pop($responseData['results']);
|
||||
if ($result['code'] < 200 || $result['code'] >= 300) {
|
||||
$errorResult = $responseData['results'][0];
|
||||
if (isset($errorResult['code']) && ($errorResult['code'] < 200 || $errorResult['code'] >= 300)) {
|
||||
throw new ApiCommandException(
|
||||
'Can\'t send external Icinga command: %u %s',
|
||||
$result['code'],
|
||||
$result['status']
|
||||
$errorResult['code'],
|
||||
$errorResult['status']
|
||||
);
|
||||
}
|
||||
|
||||
return $responseData['results'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -269,7 +271,7 @@ class ApiCommandTransport implements CommandTransportInterface
|
|||
*/
|
||||
public function send(IcingaCommand $command, $now = null)
|
||||
{
|
||||
$this->sendCommand($this->renderer->render($command));
|
||||
return $this->sendCommand($this->renderer->render($command));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -106,14 +106,14 @@ class CommandTransport implements CommandTransportInterface
|
|||
$transport = static::createTransport($transportConfig);
|
||||
|
||||
try {
|
||||
$transport->send($command, $now);
|
||||
$result = $transport->send($command, $now);
|
||||
} catch (CommandTransportException $e) {
|
||||
Logger::error($e);
|
||||
$errors[] = sprintf('%s: %s.', $name, rtrim($e->getMessage(), '.'));
|
||||
continue; // Try the next transport
|
||||
}
|
||||
|
||||
return; // The command was successfully sent
|
||||
return $result; // The command was successfully sent
|
||||
}
|
||||
|
||||
if (! empty($errors)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue