summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-09-07 21:30:32 -0400
committerJohn Turner <jturner.usa@gmail.com>2025-09-07 21:30:32 -0400
commiteb6819a5844b5be535c972c6824c7708498a7781 (patch)
treeff0b4e7daf2c0ce40e9250cb17300226b6847613
parent33fce23ae1db1abac8dd9af2d48acc8ee395c524 (diff)
downloadpypaste-eb6819a5844b5be535c972c6824c7708498a7781.tar.gz
check for error when checking if key exists in database
-rw-r--r--pypaste/__init__.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/pypaste/__init__.py b/pypaste/__init__.py
index d0991c2..36ca927 100644
--- a/pypaste/__init__.py
+++ b/pypaste/__init__.py
@@ -111,8 +111,13 @@ class App:
except KeyError:
return web.HTTPBadRequest(text="provide a key to fetch")
- if not await self.database.exists(key):
- log_info(f"paste {key} was not found, returning 404")
+ try:
+ exists = self.database.exists(key)
+ except Exception as e:
+ log_error(f"failed to check if key exists in database: {e}")
+ return web.HTTPBadRequest()
+
+ if not exists:
return web.HTTPNotFound()
req = self.bucket.get(key)