Skip to content

Commit

Permalink
ObjectInspectionDetail: Render invalid states
Browse files Browse the repository at this point in the history
  • Loading branch information
nilmerg committed Oct 27, 2023
1 parent c503f14 commit e8d4331
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions library/Icingadb/Common/ObjectInspectionDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Icinga\Module\Icingadb\Widget\Detail\CustomVarTable;
use Icinga\Util\Format;
use Icinga\Util\Json;
use InvalidArgumentException;
use ipl\Html\BaseHtmlElement;
use ipl\Html\FormattedString;
use ipl\Html\HtmlElement;
Expand Down Expand Up @@ -298,13 +299,18 @@ private function formatMilliseconds($ms): string

private function formatState(int $state)
{
switch (true) {
case $this->object instanceof Host:
return HostStates::text($state);
case $this->object instanceof Service:
return ServiceStates::text($state);
default:
return $state;
try {
switch (true) {
case $this->object instanceof Host:
return HostStates::text($state);
case $this->object instanceof Service:
return ServiceStates::text($state);
default:
return $state;
}
} catch (InvalidArgumentException $_) {
// The Icinga 2 API sometimes delivers strange details
return (string) $state;
}
}

Expand Down

0 comments on commit e8d4331

Please sign in to comment.