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);
|
||||
} catch (JsonEncodeException $e) {
|
||||
foreach ($this->objects as $type => $objects) {
|
||||
foreach ($objects as $key => $object) {
|
||||
foreach ($objects as $object) {
|
||||
try {
|
||||
JsonString::encode($object);
|
||||
} catch (JsonEncodeException $singleError) {
|
||||
if ($object instanceof IcingaObject) {
|
||||
$name = $object->getObjectName();
|
||||
} else {
|
||||
$name = var_export($object, 1);
|
||||
if (function_exists('iconv')) {
|
||||
$name = iconv('UTF-8', 'UTF-8//IGNORE', $name);
|
||||
}
|
||||
$dump = var_export($object, 1);
|
||||
if (function_exists('iconv')) {
|
||||
$dump = iconv('UTF-8', 'UTF-8//IGNORE', $dump);
|
||||
}
|
||||
throw new JsonEncodeException(sprintf(
|
||||
'Failed to encode object ot type "%s": "%s", %s',
|
||||
'Failed to encode object ot type "%s": %s, %s',
|
||||
$type,
|
||||
$name,
|
||||
$dump,
|
||||
$singleError->getMessage()
|
||||
), $singleError->getCode());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user