From 303b7b5c033e22cf27715e4a85d1c2a9c3fd66c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Moulin-Frier?= Date: Wed, 15 Jan 2025 10:46:35 +0100 Subject: [PATCH] Improve error handling in attribute access by adding a custom message for missing attributes --- vivarium/controllers/notebook_controller.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vivarium/controllers/notebook_controller.py b/vivarium/controllers/notebook_controller.py index 81f352e..3a1432a 100644 --- a/vivarium/controllers/notebook_controller.py +++ b/vivarium/controllers/notebook_controller.py @@ -39,7 +39,11 @@ def __getattr__(self, item): if item in self.config.param_names(): return getattr(self.config, item) else: - return super().__getattr__(item) + try: + return super().__getattr__(item) + except AttributeError as e: + print(f"{self.__class__.__name__} has no attribute {item}") + raise # TODO : Add a check to ensure that the attribute's value is authorized (according to params bounds) def __setattr__(self, item, val):