mirror of
https://github.com/ParisNeo/lollms.git
synced 2025-01-05 04:14:15 +00:00
22 lines
625 B
Python
22 lines
625 B
Python
import traceback
|
|
from ascii_colors import ASCIIColors
|
|
from enum import Enum
|
|
|
|
def get_trace_exception(ex):
|
|
"""
|
|
Traces an exception (useful for debug) and returns the full trace of the exception
|
|
"""
|
|
# Catch the exception and get the traceback as a list of strings
|
|
traceback_lines = traceback.format_exception(type(ex), ex, ex.__traceback__)
|
|
|
|
# Join the traceback lines into a single string
|
|
traceback_text = ''.join(traceback_lines)
|
|
return traceback_text
|
|
|
|
def trace_exception(ex):
|
|
"""
|
|
Traces an exception (useful for debug)
|
|
"""
|
|
ASCIIColors.error(get_trace_exception(ex))
|
|
|