Skip to content

Commit

Permalink
Improve error message readability (#895)
Browse files Browse the repository at this point in the history
* Improve error message readability
resolves #560

* aurtaugraf

---------

Co-authored-by: Fred Lefévère-Laoide <[email protected]>
  • Loading branch information
FredLL-Avaiga and Fred Lefévère-Laoide authored Feb 28, 2024
1 parent 9e6693d commit 5e52300
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions taipy/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,23 @@ def _manage_message(self, msg_type: _WsType, message: dict) -> None:
self.__handle_ws_app_id(message)
self.__send_ack(message.get("ack_id"))
except Exception as e: # pragma: no cover
_warn(f"Decoding Message has failed: {message}", e)
if isinstance(e, AttributeError) and (name := message.get("name")):
try:
names = self._get_real_var_name(name)
var_name = names[0] if isinstance(names, tuple) else names
var_context = names[1] if isinstance(names, tuple) else None
if var_name.startswith("tpec_"):
var_name = var_name[5:]
if var_name.startswith("TpExPr_"):
var_name = var_name[7:]
_warn(
f"A problem occurred while resolving variable '{var_name}'"
+ (f" in module '{var_context}'." if var_context else ".")
)
except Exception as e1:
_warn(f"Resolving name '{name}' failed", e1)
else:
_warn(f"Decoding Message has failed: {message}", e)

def __front_end_update(
self,
Expand Down Expand Up @@ -2017,7 +2033,7 @@ def _get_page(self, page_name: str):

def _bind_custom_page_variables(self, page: CustomPage, client_id: t.Optional[str]):
"""Handle the bindings of custom page variables"""
with self.get_flask_app().app_context() if has_app_context() else contextlib.nullcontext(): # type: ignore[attr-defined]
with self.get_flask_app().app_context() if has_app_context() else contextlib.nullcontext(): # type: ignore[attr-defined]
self.__set_client_id_in_context(client_id)
with self._set_locals_context(page._get_module_name()):
for k in self._get_locals_bind().keys():
Expand Down

0 comments on commit 5e52300

Please sign in to comment.