lollms/lollms/helpers.py
Saifeddine ALOUI 54591d660a Upgraded core
2023-12-10 22:20:58 +01:00

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))