improve handling of upload errors