code: def patch_statusreporter():
      
      from robot.running.statusreporter import StatusReporter
  
      orig_exit = StatusReporter.__exit__
  
      def __exit__(self, exc_type, exc_val, exc_tb):
          if exc_val and isinstance(exc_val, Exception):
              set_pdb_trace(pm=True)
          return orig_exit(self, exc_type, exc_val, exc_tb)
  
      StatusReporter.__exit__ = __exit__
docs: Monkey patch robotframework to do postmortem debugging