Skip to content

Commit

Permalink
added exception handler
Browse files Browse the repository at this point in the history
  • Loading branch information
almazgimaev committed Jun 18, 2024
1 parent 052f82f commit ffda070
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions agent/worker/task_logged.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,25 @@ def end_log_stop(self):
return sly.EventType.TASK_STOPPED

def end_log_crash(self, e):
exc_str = traceback.format_exc()
from supervisely.io.exception_handlers import handle_exception

trace_str = traceback.format_exc()

handled_exc = handle_exception(e)
if handled_exc is not None:
exit_status = handled_exc.title
exc_str = handled_exc.get_message_for_exception()
else:
exit_status = str(e)
exc_str = repr(e)

self.logger.warn(
"TASK_END",
extra={
"event_type": sly.EventType.TASK_CRASHED,
"exit_status": str(e),
"exc_str": repr(e),
"trace": exc_str,
"exit_status": exit_status,
"exc_str": exc_str,
"trace": trace_str,
},
)
return sly.EventType.TASK_CRASHED
Expand Down

0 comments on commit ffda070

Please sign in to comment.