Skip to content

Commit 70626fc

Browse files
committed
Better user facing errors for [chipflow.top]
1 parent 1f43de9 commit 70626fc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

chipflow_lib/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,18 @@ class ChipFlowError(Exception):
2323

2424

2525
def _get_cls_by_reference(reference, context):
26+
logger.debug(f"_get_cls_by_reference({reference}, {context}")
2627
module_ref, _, class_ref = reference.partition(":")
2728
try:
2829
module_obj = importlib.import_module(module_ref)
2930
except ModuleNotFoundError as e:
30-
raise ChipFlowError(f"Module `{module_ref}` referenced by {context} is not found") from e
31+
logger.debug(f"import_module({module_ref}) caused {e}")
32+
raise ChipFlowError(f"Module `{module_ref}` was not found (referenced by {context} in [chipflow.top])")
3133
try:
3234
return getattr(module_obj, class_ref)
3335
except AttributeError as e:
34-
raise ChipFlowError(f"Module `{module_ref}` referenced by {context} does not define "
35-
f"`{class_ref}`") from e
36+
logger.debug(f"getattr({module_obj}, {class_ref}) caused {e}")
37+
raise ChipFlowError(f"Class `{class_ref}` not found in module `{module_ref}` (referenced by {context} in [chipflow.top])")
3638

3739

3840
def _ensure_chipflow_root():

0 commit comments

Comments
 (0)