code: def move_temp_file(src, dest):
      
      try:
          move_file(src, dest)
      except Exception:
          try:
              os.remove(src)
          except Exception as ex_clean:
              # at this point, something's deeply wrong, so log error.
              # raising the original error, though, not this error in the
              # error handler, as the 1st was the initial cause of all of
              # this.
              logger.error(f"error removing temp file {src}. "
                           f"{ex_clean}")
  
          raise
docs: Move src to dest. Delete src if something goes wrong.
  
      Overwrites dest.
  
      Args:
          src: str or path-like. source file
          dest: str or path-like. destination file
  
      Returns:
          None.
  
      Raises:
          FileNotFoundError: out path parent doesn't exist.
          OSError: if any IO operations go wrong. Does its best to clean up after
                   itself and remove temp files.