Add error-handling to upload middleware