Improve Event handler Error message (#2019)

This commit is contained in:
Elijah Ahianyo 2023-10-24 17:28:51 +00:00 committed by GitHub
parent 81053618c9
commit b8f0674556
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -264,7 +264,12 @@ class Component(Base, ABC):
for v in value:
if isinstance(v, EventHandler):
# Call the event handler to get the event.
event = call_event_handler(v, arg_spec) # type: ignore
try:
event = call_event_handler(v, arg_spec) # type: ignore
except ValueError as err:
raise ValueError(
f" {err} defined in the `{type(self).__name__}` component"
) from err
# Add the event to the chain.
events.append(event)

View File

@ -479,8 +479,8 @@ def call_event_handler(
else:
source = inspect.getsource(arg_spec) # type: ignore
raise ValueError(
f"number of arguments in {event_handler.fn.__name__} "
f"doesn't match the definition '{source.strip().strip(',')}'"
f"number of arguments in {event_handler.fn.__qualname__} "
f"doesn't match the definition of the event trigger '{source.strip().strip(',')}'"
)
else:
console.deprecate(