Hi,
In the error panel of a running Dash app, many times only a partial (often minimal) stack trace is present. In particular, the line number in my code that triggers the error is missing. This makes it more laborious for me (the developer) to find what triggered the error. An example is posted below. (Note: In this case, there is no line number at all; in some other cases, there will be some line numbers indicated, but they will belong to some Python module (e.g. Pandas) and not my (the developer’s) code.)
Is it possible to always include the line number of the triggering statement in the developer’s code in the Dash app’s error panel?
Many thanks
Anirban
############### Example ################
UnboundLocalError: cannot access local variable ‘_pending_action’ where it is not associated with a value
Traceback (most recent call last)
UnboundLocalError: cannot access local variable ‘_pending_action’ where it is not associated with a value
This is the Copy/Paste friendly version of the traceback.
UnboundLocalError: cannot access local variable ‘_pending_action’ where it is not associated with a value
Hi Aimped,
In this case, yes, this is the only one.
Note that I’m not asking how to fix this particular error (I already fixed it). What I’m asking is if there is a way to make the error messages more friendly to developers by ALWAYS adding the line number in the developer’s code that triggered it.
I have noticed that when there isn’t any line number at all, its often when the error is because of an undefined variable, or encountering a Nonetype value when a concrete value is expected.
File "/usr/local/packages/anaconda3/envs/plotly/lib/python3.12/site-packages/pandas/core/indexes/base.py", line 3790, in get_loc
return self._engine.get_loc(casted_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "index.pyx", line 152, in pandas._libs.index.IndexEngine.get_loc
File "index.pyx", line 181, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 7080, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 7088, in pandas._libs.hashtable.PyObjectHashTable.get_item
The above exception was the direct cause of the following exception:
KeyError: 't'
This is the Copy/Paste friendly version of the traceback.
Traceback (most recent call last):
File “/usr/local/packages/anaconda3/envs/plotly/lib/python3.12/site-packages/pandas/core/indexes/base.py”, line 3790, in get_loc
return self._engine.get_loc(casted_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “index.pyx”, line 152, in pandas._libs.index.IndexEngine.get_loc
File “index.pyx”, line 181, in pandas._libs.index.IndexEngine.get_loc
File “pandas/_libs/hashtable_class_helper.pxi”, line 7080, in pandas._libs.hashtable.PyObjectHashTable.get_item
File “pandas/_libs/hashtable_class_helper.pxi”, line 7088, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: ‘t’
The above exception was the direct cause of the following exception: