fix error handling when uploading