From 4819de146880dfb675f8e75921ab0f180c04ac70 Mon Sep 17 00:00:00 2001 From: Alejandro Villar Date: Thu, 4 Jul 2024 09:36:31 +0200 Subject: [PATCH] Fix validation with no schema and improve error reporting --- ogc/bblocks/validate.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ogc/bblocks/validate.py b/ogc/bblocks/validate.py index a0952e0..ad1a2e8 100644 --- a/ogc/bblocks/validate.py +++ b/ogc/bblocks/validate.py @@ -732,14 +732,17 @@ def validate_test_resources(bblock: BuildingBlock, schema_url = next((u for u in bblock.metadata.get('schema', []) if u.endswith('.json')), None) try: - if bblock.annotated_schema: + if bblock.annotated_schema.is_file(): schema_validator = get_json_validator(bblock.annotated_schema_contents, bblock.annotated_schema.resolve().as_uri(), bblocks_register) + except Exception as e: + json_error = f"Error creating JSON validator: {type(e).__name__}: {e}" + try: if bblock.jsonld_context.is_file(): jsonld_context = load_yaml(filename=bblock.jsonld_context) except Exception as e: - json_error = f"{type(e).__name__}: {e}" + json_error = f"Error loading JSON-LD context: {type(e).__name__}: {e}" if outputs_path: output_dir = outputs_path / bblock.subdirs