summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Klug <stefan.klug@ideasonboard.com>2024-12-04 12:10:13 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-12-05 22:29:57 +0200
commitfa0013c953b488ae421e66c0de726bf351072589 (patch)
treeb6f0a8d5860ade27358229d8115025a474db12d5
parent9fc86dc02ac227a5af14e19f7f6253df377fd2e8 (diff)
libcamera: yaml_parser: Output more details when parsing fails
On malformed yaml files, the yaml parser only errors out without giving details on the error that happened. Fix that by providing a more detailed error message. Output old: ERROR YamlParser yaml_parser.cpp:886 Failed to parse YAML content from /root/imx283.yaml Output new: ERROR YamlParser yaml_parser.cpp:627 /root/imx283.yaml:72:8 could not find expected ':' while scanning a simple key ERROR YamlParser yaml_parser.cpp:886 Failed to parse YAML content from /root/imx283.yaml Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--src/libcamera/yaml_parser.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp
index db256ec5..f9302c4e 100644
--- a/src/libcamera/yaml_parser.cpp
+++ b/src/libcamera/yaml_parser.cpp
@@ -509,8 +509,17 @@ YamlParserContext::EventPtr YamlParserContext::nextEvent()
EventPtr event(new yaml_event_t);
/* yaml_parser_parse returns 1 when it succeeds */
- if (!yaml_parser_parse(&parser_, event.get()))
+ if (!yaml_parser_parse(&parser_, event.get())) {
+ File *file = static_cast<File *>(parser_.read_handler_data);
+
+ LOG(YamlParser, Error) << file->fileName() << ":"
+ << parser_.problem_mark.line << ":"
+ << parser_.problem_mark.column << " "
+ << parser_.problem << " "
+ << parser_.context;
+
return nullptr;
+ }
return event;
}