Raised exceptions should print more information, e.g. stacktrace and line number
gbritoda opened this issue · 1 comments
gbritoda commented
Description
When you get exceptions on callbacks you only get the description. You don't get where it happened or which exception. Can make complex projects confusing and hard to debug.
Examples:
page = """
<|button|label=Press for errors|on_action=raise_exceptions|>
"""
def raise_exceptions(state:State):
raise KeyError("This is an KeyError")
# This would give us:
# TaipyGuiWarning: on_action(): Exception raised in 'raise_exceptions()':
# 'This is an KeyError'
# TaipyGuiWarning: on_action(): 'raise_exceptions' is not a valid function.
page = """
<|button|label=Press for errors|on_action=raise_exceptions|>
"""
def raise_exceptions(state:State):
assert False, "This is an assertion error message!"
# This would give us:
# TaipyGuiWarning: on_action(): Exception raised in 'raise_exceptions()':
# This is an assertion error message!
# TaipyGuiWarning: on_action(): 'raise_exceptions' is not a valid function.
Only workaround I know is using the traceback
library:
from taipy.gui import State, Gui
import traceback
page = """
<|button|label=Press for errors|on_action=raise_exceptions|>
"""
def raise_exceptions(state:State):
try:
raise KeyError("This is an KeyError")
except:
traceback.print_exc()
raise
# This would give you:
# Traceback (most recent call last):
# File "/path/to/file.py", line 8, in raise_exceptions
# raise KeyError("This is an KeyError")
# KeyError: 'This is an KeyError'
# TaipyGuiWarning: on_action(): Exception raised in 'raise_exceptions()':
# 'This is an KeyError'
# TaipyGuiWarning: on_action(): 'raise_exceptions' is not a valid function.
Acceptance Criteria
- Raised exceptions print stack trace and line number
or - A flag that enables us to do this, in case this is being hidden on purpose
FredLL-Avaiga commented
as a workaround you can use the on_exception callback
We're thinking of finding a way to activate a stack trace globally...