From: Michael Tremer Date: Fri, 20 Oct 2023 09:49:05 +0000 (+0000) Subject: builds: Update API error response codes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9cea0d62ccfdadc57c16fee064c5f2332d1fa16d;p=pbs.git builds: Update API error response codes Signed-off-by: Michael Tremer --- diff --git a/src/web/builds.py b/src/web/builds.py index 0cd35bd8..be8bef0d 100644 --- a/src/web/builds.py +++ b/src/web/builds.py @@ -1,5 +1,6 @@ #!/usr/bin/python +import errno import tornado.web from ..errors import NoSuchDistroError @@ -15,13 +16,13 @@ class APIv1IndexHandler(base.APIMixin, base.BaseHandler): @base.negotiate async def post(self): # Fetch the upload - upload = self.get_argument_upload("upload_id") + upload = self.get_argument_upload("upload") if not upload: raise tornado.web.HTTPError(404, "Could not find upload") # Check permissions of the upload if not upload.has_perm(self.current_user): - raise tornado.web.HTTPError(403, "No permission for using upload %s" % upload) + raise base.APIError(errno.ENOPERM, "No permission for using upload %s" % upload) # Fetch the repository repo_name = self.get_argument("repo", None) @@ -37,13 +38,13 @@ class APIv1IndexHandler(base.APIMixin, base.BaseHandler): # If the distribution that is coded into the package could not be found, # we will send that error to the user... except NoSuchDistroError as e: - raise tornado.web.HTTPError(404, "Could not find distribution: %s" % e) + raise base.APIError(errno.ENOENT, "Could not find distribution: %s" % e) try: # Find the repository repo = self.current_user.get_repo(package.distro, repo_name) if not repo: - raise tornado.web.HTTPError(404, "Could not find repository") + raise base.APIError(errno.ENOENT, "Could not find repository") # Create a new build build = await self.backend.builds.create(repo, package,