mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
BasketSnapshot: simplify error handling
We have no IcingaObject here, they're all stdClass instances
This commit is contained in:
parent
470137b5c2
commit
ad5dfc8496
@ -424,22 +424,18 @@ class BasketSnapshot extends DbObject
|
|||||||
return JsonString::encode($this->objects, JSON_PRETTY_PRINT);
|
return JsonString::encode($this->objects, JSON_PRETTY_PRINT);
|
||||||
} catch (JsonEncodeException $e) {
|
} catch (JsonEncodeException $e) {
|
||||||
foreach ($this->objects as $type => $objects) {
|
foreach ($this->objects as $type => $objects) {
|
||||||
foreach ($objects as $key => $object) {
|
foreach ($objects as $object) {
|
||||||
try {
|
try {
|
||||||
JsonString::encode($object);
|
JsonString::encode($object);
|
||||||
} catch (JsonEncodeException $singleError) {
|
} catch (JsonEncodeException $singleError) {
|
||||||
if ($object instanceof IcingaObject) {
|
$dump = var_export($object, 1);
|
||||||
$name = $object->getObjectName();
|
if (function_exists('iconv')) {
|
||||||
} else {
|
$dump = iconv('UTF-8', 'UTF-8//IGNORE', $dump);
|
||||||
$name = var_export($object, 1);
|
|
||||||
if (function_exists('iconv')) {
|
|
||||||
$name = iconv('UTF-8', 'UTF-8//IGNORE', $name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
throw new JsonEncodeException(sprintf(
|
throw new JsonEncodeException(sprintf(
|
||||||
'Failed to encode object ot type "%s": "%s", %s',
|
'Failed to encode object ot type "%s": %s, %s',
|
||||||
$type,
|
$type,
|
||||||
$name,
|
$dump,
|
||||||
$singleError->getMessage()
|
$singleError->getMessage()
|
||||||
), $singleError->getCode());
|
), $singleError->getCode());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user