code: def last_exception():
      
      exc_type, exc_value, exc_traceback = sys.exc_info()
      return "".join(traceback.format_exception(exc_type, exc_value, exc_traceback))
docs: Returns last exception as a string, or use in logging.