import traceback def get_full_traceback(e: Exception) -> str: """ Returns full formatted traceback information from an exception object. Args: e (Exception): The exception object Returns: str: Formatted traceback string """ # Get exception info as a list of strings tb_lines = traceback.format_exception(type(e), e, e.__traceback__) # Join lines into single string full_traceback = ''.join(tb_lines) return full_traceback if __name__ == "__main__": # Usage example: try: # Some code that may raise exception raise ValueError("Example error") except Exception as e: error_trace = get_full_traceback(e) print(error_trace)