INNER CODE UNIT · Python
__handle_agent_exception
handrew/browserpilot · browserpilot/agents/gpt_selenium_agent.py:314
def __handle_agent_exception(self, action):
"""To be used in a try/except block to handle exceptions."""
stack_trace_result = self.__get_relevant_part_of_stack_trace()
stack_trace = stack_trace_result["stack_trace"]
line_num = stack_trace_result["line_num"]
problem_instruction = "\nFailed on line: {line}\n".format(
line=action.split("\n")[line_num - 1]
)
logger.info("\n\n" + stack_trace)
logger.info(problem_instruction)
if self.debug:
if self.debug_html_folder:
self.__save_html_snapshot()
logger.info(traceback.print_exc())
logger.info(
"Starting interactive debugger. Type `env` for the Agent object."