properly handle upload errors