# #
###############################################################################
+import errno
import io
import tornado.web
)
except uploads.UnsupportedDigestException as e:
- raise base.APIError(400, "Unsupported digest %s" % digest_algo) from e
+ raise base.APIError(errno.ENOTSUP, "Unsupported digest %s" % digest_algo) from e
except users.QuotaExceededError as e:
- raise base.APIError(400, "Quota exceeded for %s" % self.current_user) from e
+ raise base.APIError(errno.EDQUOT, "Quota exceeded for %s" % self.current_user) from e
except ValueError as e:
- raise base.APIError(400, "%s" % e) from e
+ raise base.APIError(errno.EINVAL, "%s" % e) from e
# Send the ID of the upload back to the client
self.finish({
# Fetch the upload
upload = self.backend.uploads.get_by_uuid(uuid)
if not upload:
- raise tornado.web.HTTPError(404, "Could not find upload %s" % uuid)
+ raise tornado.web.HTTPError(400, "Could not find upload %s" % uuid)
# Fail if we did not receive anything
if not self.buffer.tell():
- raise tornado.web.HTTPError(400, "No data received")
+ raise base.APIError(errno.ENODATA, "No data received")
# Import the payload from the buffer
with self.db.transaction():
await upload.copyfrom(self.buffer)
except ValueError as e:
- raise base.APIError(400, "%s" % e) from e
+ raise base.APIError(errno.EINVAL, "%s" % e) from e
# Send a positive response
self.finish({})