add try except around compare

This commit is contained in:
Khaleel Al-Adhami 2024-10-15 15:10:12 -07:00
parent 9ce6320940
commit 437848f5b9

View File

@ -1049,9 +1049,16 @@ def call_event_handler(
if arg not in type_hints_of_provided_callback:
continue
if compare_types(
try:
compare_result = compare_types(
args_types_without_vars[i], type_hints_of_provided_callback[arg]
):
)
except TypeError as e:
raise TypeError(
f"Could not compare types {args_types_without_vars[i]} and {type_hints_of_provided_callback[arg]} for argument {arg} of {event_handler.fn.__qualname__}."
) from e
if compare_result:
continue
else:
raise EventHandlerArgTypeMismatch(