]> git.ipfire.org Git - ipfire.org.git/commitdiff
dbl: Always catch 404 and return None
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 14 Jan 2026 14:50:40 +0000 (14:50 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 14 Jan 2026 14:50:40 +0000 (14:50 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/dbl.py

index 39b42f57766a10241c0b60235db43b85de722d5f..ce19b21953020e2d1e11ed06d465e25e4d0288e2 100644 (file)
@@ -53,9 +53,17 @@ class DBL(Object):
                        body = json.dumps(body)
 
                # Send the request
-               response = await self.backend.http_client.fetch(
-                       url, headers=headers, body=body, **kwargs,
-               )
+               try:
+                       response = await self.backend.http_client.fetch(
+                               url, headers=headers, body=body, **kwargs,
+                       )
+
+               # Return nothing if we received 404
+               except tornado.httpclient.HTTPClientError as e:
+                       if e.code == 404:
+                               return
+
+                       raise e
 
                # Decode the response
                return json.loads(response.body)
@@ -69,18 +77,11 @@ class DBL(Object):
                return [List(self.backend, **list) for list in response]
 
        async def get_list(self, slug):
-               try:
-                       response = await self._fetch("/lists/%s" % slug)
-
-               # Return nothing if we received 404
-               except tornado.httpclient.HTTPClientError as e:
-                       if e.code == 404:
-                               return
-
-                       raise e
+               response = await self._fetch("/lists/%s" % slug)
 
                # Return the list
-               return List(self.backend, **response)
+               if response:
+                       return List(self.backend, **response)
 
        # Reports
 
@@ -88,18 +89,11 @@ class DBL(Object):
                """
                        Fetches a report
                """
-               try:
-                       response = await self._fetch("/reports/%s" % id)
-
-               # Return nothing if we received 404
-               except tornado.httpclient.HTTPClientError as e:
-                       if e.code == 404:
-                               return
-
-                       raise e
+               response = await self._fetch("/reports/%s" % id)
 
                # Return the report
-               return Report(self.backend, **response)
+               if response:
+                       return Report(self.backend, **response)
 
        # Search!