MCPcopy Create free account
hub / github.com/OpenCodeInterpreter/OpenCodeInterpreter / clean_error_msg

Function clean_error_msg

demo/utils/cleaner.py:15–31  ·  view source on GitHub ↗
(error_str:str ='')

Source from the content-addressed store, hash-verified

13 return '' # Return None if no error message is found
14
15def clean_error_msg(error_str:str =''):
16 filtered_error_msg = error_str.__str__().split('An error occurred while executing the following cell')[-1].split("\n------------------\n")[-1]
17 raw_error_msg = "".join(filtered_error_msg)
18
19 # Remove escape sequences for colored text
20 ansi_escape = re.compile(r'\x1b\[[0-?]*[ -/]*[@-~]')
21 error_msg = ansi_escape.sub('', raw_error_msg)
22
23 error_str_out = ''
24 error_msg_only_cell = error_msg.split(SITE_PKG_ERROR_PREFIX)
25
26 error_str_out += f'{error_msg_only_cell[0]}\n'
27 error_header = get_error_header(error_msg_only_cell[-1])
28 if error_header not in error_str_out:
29 error_str_out += get_error_header(error_msg_only_cell[-1])
30
31 return error_str_out

Callers

nothing calls this directly

Calls 2

get_error_headerFunction · 0.85
__str__Method · 0.45

Tested by

no test coverage detected