From 26b46ac0d775bde54b5e2ed66118e2266d4fc1d5 Mon Sep 17 00:00:00 2001 From: Alexander Schlemmer <alexander@mail-schlemmer.de> Date: Tue, 9 Jan 2024 10:16:26 +0100 Subject: [PATCH] ENH: more detailed reporting of errors in converters --- src/caoscrawler/converters.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/caoscrawler/converters.py b/src/caoscrawler/converters.py index c8f4d229..417c0b5b 100644 --- a/src/caoscrawler/converters.py +++ b/src/caoscrawler/converters.py @@ -590,6 +590,15 @@ class MarkdownFileConverter(SimpleFileConverter): "Error during the validation (yaml header cannot be read) of the markdown file " "located at the following node in the data structure:\n" f"{path}") + except yaml_header_tools.ParseErrorsInHeader as err: + if generalStore is not None and self.name in generalStore: + path = generalStore[self.name] + else: + path = "<path not set>" + raise ConverterValidationError( + "Error during the validation (yaml header cannot be read) of the markdown file " + "located at the following node in the data structure:\n" + "{}\nError:\n{}".format(path, err)) children: List[StructureElement] = [] for name, entry in header.items(): @@ -598,8 +607,12 @@ class MarkdownFileConverter(SimpleFileConverter): elif type(entry) == str: children.append(TextElement(name, entry)) else: + if generalStore is not None and self.name in generalStore: + path = generalStore[self.name] + else: + path = "<path not set>" raise RuntimeError( - "Header entry {} has incompatible type.".format(name)) + "Header entry {} has incompatible type.\nFilename: {}".format(name, path)) return children -- GitLab