From 437848f5b9d2e43dfc29ce238a2e3116a1ad98b8 Mon Sep 17 00:00:00 2001 From: Khaleel Al-Adhami Date: Tue, 15 Oct 2024 15:10:12 -0700 Subject: [PATCH] add try except around compare --- reflex/event.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/reflex/event.py b/reflex/event.py index 8730bbcac..0a9664e62 100644 --- a/reflex/event.py +++ b/reflex/event.py @@ -1049,9 +1049,16 @@ def call_event_handler( if arg not in type_hints_of_provided_callback: continue - if compare_types( - args_types_without_vars[i], type_hints_of_provided_callback[arg] - ): + 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(