mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-29 16:54:06 +02:00
IcingaEndpoint: give meaningful error...
...when trying to get an ApiUser where there is no such
This commit is contained in:
parent
b4c05738ae
commit
d13919681a
@ -8,6 +8,7 @@ use Icinga\Module\Director\Core\RestApiClient;
|
||||
use Icinga\Module\Director\Exception\NestingError;
|
||||
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
|
||||
class IcingaEndpoint extends IcingaObject
|
||||
{
|
||||
@ -42,10 +43,12 @@ class IcingaEndpoint extends IcingaObject
|
||||
|
||||
public function getApiUser()
|
||||
{
|
||||
return $this->getRelatedObject(
|
||||
'apiuser',
|
||||
$this->getResolvedProperty('apiuser_id')
|
||||
);
|
||||
$id = $this->getResolvedProperty('apiuser_id');
|
||||
if ($id === null) {
|
||||
throw new RuntimeException('Trying to get API User for Endpoint without such: ' . $this->getObjectName());
|
||||
}
|
||||
|
||||
return $this->getRelatedObject('apiuser', $id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user