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 <markus.zolliker@psi.ch>
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
This commit is contained in:
zolliker 2025-03-28 15:14:31 +01:00
parent 3b8f3586cf
commit aea56bb16a
2 changed files with 6 additions and 2 deletions

View File

@ -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):

View File

@ -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')