mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
YAML parser: filter unexpected part from the parse exception message (#4759)
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
+7
-2
@@ -91,6 +91,8 @@ public class YamlModelRepositoryImpl implements WatchService.WatchEventListener,
|
||||
getElementName(YamlThingDTO.class) // "things"
|
||||
);
|
||||
|
||||
private static final String UNWANTED_EXCEPTION_TEXT = "at [Source: UNKNOWN; byte offset: #UNKNOWN] ";
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(YamlModelRepositoryImpl.class);
|
||||
|
||||
private final WatchService watchService;
|
||||
@@ -709,8 +711,9 @@ public class YamlModelRepositoryImpl implements WatchService.WatchEventListener,
|
||||
return Optional.of(objectMapper.treeToValue(node, elementClass));
|
||||
} catch (JsonProcessingException e) {
|
||||
if (errors != null) {
|
||||
String msg = e.getMessage();
|
||||
errors.add("Could not parse element %s to %s: %s".formatted(node.toPrettyString(),
|
||||
elementClass.getSimpleName(), e.getMessage()));
|
||||
elementClass.getSimpleName(), msg == null ? "" : msg.replace(UNWANTED_EXCEPTION_TEXT, "")));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
@@ -743,8 +746,10 @@ public class YamlModelRepositoryImpl implements WatchService.WatchEventListener,
|
||||
elt.setId(id);
|
||||
} catch (JsonProcessingException e) {
|
||||
if (errors != null) {
|
||||
String msg = e.getMessage();
|
||||
errors.add("could not parse element %s to %s: %s".formatted(node.toPrettyString(),
|
||||
elementClass.getSimpleName(), e.getMessage()));
|
||||
elementClass.getSimpleName(),
|
||||
msg == null ? "" : msg.replace(UNWANTED_EXCEPTION_TEXT, "")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user