From aea56bb16af1c3fd000a7d9c5dfb62b12346b73a Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Fri, 28 Mar 2025 15:14:31 +0100 Subject: [PATCH] improve error messages on module creation - add name when target and value datatype are incompatible - check that module class inherits from Module Change-Id: I4edbdff1c250b64b74b1adf7287f9659dff69b26 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/35931 Reviewed-by: Markus Zolliker Tested-by: Jenkins Automated Tests --- frappy/modules.py | 4 ++-- frappy/secnode.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/frappy/modules.py b/frappy/modules.py index 802e2d1..241a9bc 100644 --- a/frappy/modules.py +++ b/frappy/modules.py @@ -68,8 +68,8 @@ class Writable(Readable): target_dt.compatible(value_dt) except Exception: if type(value_dt) == type(target_dt): - raise ConfigError('the target range extends beyond the value range') from None - raise ProgrammingError('the datatypes of target and value are not compatible') from None + raise ConfigError(f'{name}: the target range extends beyond the value range') from None + raise ProgrammingError(f'{name}: the datatypes of target and value are not compatible') from None class Drivable(Writable): diff --git a/frappy/secnode.py b/frappy/secnode.py index 65dc633..73cb56b 100644 --- a/frappy/secnode.py +++ b/frappy/secnode.py @@ -27,6 +27,7 @@ from frappy.dynamic import Pinata from frappy.errors import ConfigError, NoSuchModuleError, NoSuchParameterError from frappy.lib import get_class from frappy.version import get_version +from frappy.modules import Module class SecNode: @@ -131,6 +132,9 @@ class SecNode: # creation has failed already once, do not try again return None cls = classname + if not issubclass(cls, Module): + self.errors.append(f'{cls.__name__} is not a Module') + return None except Exception as e: if str(e) == 'no such class': self.errors.append(f'{classname} not found')