From 04642a6ec7f7cb5fd421ab0b5f821da0126a24c7 Mon Sep 17 00:00:00 2001 From: Rahil Doshi <rahil.doshi@fau.de> Date: Sat, 1 Mar 2025 21:38:39 +0100 Subject: [PATCH] Improve error messages for YAML configuration validation --- src/pymatlib/core/yaml_parser.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pymatlib/core/yaml_parser.py b/src/pymatlib/core/yaml_parser.py index a0b29e0..23fb778 100644 --- a/src/pymatlib/core/yaml_parser.py +++ b/src/pymatlib/core/yaml_parser.py @@ -79,14 +79,16 @@ class MaterialConfigParser: def _validate_config(self) -> None: """Validate YAML configuration structure and content.""" if not isinstance(self.config, dict): - raise ValueError("Root YAML element must be a mapping") + # raise ValueError("Root YAML element must be a mapping") + raise ValueError("The YAML file must start with a dictionary/object structure with key-value pairs, not a list or scalar value") if 'properties' not in self.config: raise ValueError("Missing 'properties' section in configuration") properties = self.config.get('properties', {}) if not isinstance(properties, dict): - raise ValueError("'properties' must be a mapping") + # raise ValueError("'properties' must be a mapping") + raise ValueError("The 'properties' section in your YAML file must be a dictionary with key-value pairs") self._validate_property_names(properties) self._validate_required_fields() -- GitLab