diff --git a/chanfig/registry.py b/chanfig/registry.py index c3973052..6c5acd07 100644 --- a/chanfig/registry.py +++ b/chanfig/registry.py @@ -206,10 +206,12 @@ def lookup(self, name: str, default: Any = Null) -> Any: if default is Null: default = self.getattr("default", Null) - element = self.get(name, default) - if isinstance(element, Registry): - return element.getattr("default") - return element + component = self.get(name, default) + if isinstance(component, Registry): + component = component.getattr("default") + if component is Null: + raise KeyError(f"Component with name {name} not registered.") + return component @staticmethod def init(cls: Callable, *args: Any, **kwargs: Any) -> Any: # pylint: disable=W0211