feat: get_traceback with context
This commit is contained in:
parent
c1e477ce5d
commit
4e533682ba
3 changed files with 13 additions and 6 deletions
|
|
@ -354,11 +354,11 @@ def cache() -> "RedisWrapper":
|
|||
return redis_server
|
||||
|
||||
|
||||
def get_traceback():
|
||||
def get_traceback(with_context=False):
|
||||
"""Returns error traceback."""
|
||||
from frappe.utils import get_traceback
|
||||
|
||||
return get_traceback()
|
||||
return get_traceback(with_context=with_context)
|
||||
|
||||
|
||||
def errprint(msg):
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ from typing import Generator, Iterable
|
|||
from urllib.parse import quote, urlparse
|
||||
|
||||
from redis.exceptions import ConnectionError
|
||||
from traceback_with_variables import iter_exc_lines
|
||||
from werkzeug.test import Client
|
||||
|
||||
import frappe
|
||||
|
|
@ -255,7 +256,7 @@ def get_gravatar(email):
|
|||
return gravatar_url
|
||||
|
||||
|
||||
def get_traceback() -> str:
|
||||
def get_traceback(with_context=False) -> str:
|
||||
"""
|
||||
Returns the traceback of the Exception
|
||||
"""
|
||||
|
|
@ -264,10 +265,15 @@ def get_traceback() -> str:
|
|||
if not any([exc_type, exc_value, exc_tb]):
|
||||
return ""
|
||||
|
||||
trace_list = traceback.format_exception(exc_type, exc_value, exc_tb)
|
||||
bench_path = get_bench_path() + "/"
|
||||
if with_context:
|
||||
trace_list = iter_exc_lines()
|
||||
tb = "\n".join(trace_list)
|
||||
else:
|
||||
trace_list = traceback.format_exception(exc_type, exc_value, exc_tb)
|
||||
tb = "".join(cstr(t) for t in trace_list)
|
||||
|
||||
return "".join(cstr(t) for t in trace_list).replace(bench_path, "")
|
||||
bench_path = get_bench_path() + "/"
|
||||
return tb.replace(bench_path, "")
|
||||
|
||||
|
||||
def log(event, details):
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ semantic-version~=2.8.5
|
|||
sqlparse~=0.4.1
|
||||
stripe~=2.56.0
|
||||
terminaltables~=3.1.0
|
||||
traceback-with-variables~=2.0.4
|
||||
urllib3~=1.26.4
|
||||
Werkzeug~=2.0.3
|
||||
Whoosh~=2.7.4
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue