Skip to content

Commit cbdf074

Browse files
committed
Improve error reporting
1 parent 2b5877b commit cbdf074

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

ogc/bblocks/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def __init__(self,
451451
self.bblock_paths[bblock.files_path] = bblock
452452
except Exception as e:
453453
if fail_on_error:
454-
raise
454+
raise Exception(f'Error encountered while loading bblock: {bblock_id}') from e
455455
print('==== Exception encountered while processing', bblock_id, '====', file=sys.stderr)
456456
import traceback
457457
traceback.print_exception(e, file=sys.stderr)

ogc/bblocks/postprocess.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def do_postprocess(bblock: BuildingBlock, light: bool = False) -> bool:
286286
print(f" - {annotated}", file=sys.stderr)
287287
except Exception as e:
288288
if fail_on_error:
289-
raise
289+
raise Exception(f"Error annotating schema for {building_block.identifier}") from e
290290
traceback.print_exception(e, file=sys.stderr)
291291
if isinstance(e, ContextLoadError):
292292
if e.__cause__:
@@ -328,8 +328,8 @@ def do_postprocess(bblock: BuildingBlock, light: bool = False) -> bool:
328328
building_block.metadata['ontology'] = building_block.ontology.value
329329
except Exception as e:
330330
if fail_on_error:
331-
raise BuildingBlockError(f'Error processing ontology for {building_block.identifier}')\
332-
from e
331+
raise BuildingBlockError(f'Error processing ontology '
332+
f'for {building_block.identifier}') from e
333333
print("Exception when processing ontology for", building_block.identifier, file=sys.stderr)
334334
traceback.print_exception(e, file=sys.stderr)
335335

@@ -338,6 +338,9 @@ def do_postprocess(bblock: BuildingBlock, light: bool = False) -> bool:
338338
base_url + os.path.relpath(building_block.remote_cache_dir.resolve(), cwd) + '/'
339339
)
340340

341+
if isinstance(building_block.metadata.get('schema'), str):
342+
building_block.metadata['schema'] = {'application/yaml': building_block.metadata['schema']}
343+
341344
child_bblocks.append(building_block)
342345

343346
if not steps or 'jsonld' in steps:
@@ -366,7 +369,7 @@ def do_postprocess(bblock: BuildingBlock, light: bool = False) -> bool:
366369
print(f" - {os.path.relpath(written_context)}", file=sys.stderr)
367370
except Exception as e:
368371
if fail_on_error:
369-
raise e
372+
raise Exception(f'Error writing context for {building_block.identifier}') from e
370373
print(f"[Error] Writing context for {building_block.identifier}: {type(e).__name__}: {e}")
371374

372375
output_bblocks = []

0 commit comments

Comments
 (0)