Improve Event handler Error message (#2019)
This commit is contained in:
parent
81053618c9
commit
b8f0674556
@ -264,7 +264,12 @@ class Component(Base, ABC):
|
|||||||
for v in value:
|
for v in value:
|
||||||
if isinstance(v, EventHandler):
|
if isinstance(v, EventHandler):
|
||||||
# Call the event handler to get the event.
|
# 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.
|
# Add the event to the chain.
|
||||||
events.append(event)
|
events.append(event)
|
||||||
|
@ -479,8 +479,8 @@ def call_event_handler(
|
|||||||
else:
|
else:
|
||||||
source = inspect.getsource(arg_spec) # type: ignore
|
source = inspect.getsource(arg_spec) # type: ignore
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"number of arguments in {event_handler.fn.__name__} "
|
f"number of arguments in {event_handler.fn.__qualname__} "
|
||||||
f"doesn't match the definition '{source.strip().strip(',')}'"
|
f"doesn't match the definition of the event trigger '{source.strip().strip(',')}'"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
console.deprecate(
|
console.deprecate(
|
||||||
|
Loading…
Reference in New Issue
Block a user