I am running a middle sized django project, whenever a error occurs a traceback is printed, but many functions where Django modules.
But the actual culprit in my own project code, it has only one line, and useful context were hidden because of the traceback depth limit. So I am thinking of filter the call stack by module path instead of call depth.
In case you haven't seen this problem, I have an very similar example in Java. What I need is to make sure the business logic code shows upfront in an exception.
While I am aware of traceback.print_exc()
, but you need to wrap every code in a try ... except
.
Is it possible to change python's default traceback behavior so django's call stack is fewer and my own code is larger portion?