Skip to content
Snippets Groups Projects
Commit 35640131 authored by Simon Künzel's avatar Simon Künzel
Browse files

Fix announcement query error handling

parent db2e2330
No related branches found
No related tags found
No related merge requests found
...@@ -32,15 +32,18 @@ def api_route_status(): ...@@ -32,15 +32,18 @@ def api_route_status():
if api.live_config.is_readonly(): if api.live_config.is_readonly():
status = "readonly" status = "readonly"
# noinspection PyBroadException # noinspection PyBroadException
query = Announcement.select(is_mod, to_load=[])
db_rows = []
try: try:
announcements.extend(map( db_rows = database.query_all_and_expunge(query)
lambda a: a.serialize(is_mod=is_mod),
database.query_all_and_expunge(Announcement.select(is_mod, to_load=[]))
))
except Exception: except Exception:
# We do NOT return status 'unavailable' because the status is the EXPECTED status. If there is an unexpected # We do NOT return status 'unavailable' because the status is the EXPECTED status. If there is an unexpected
# db failure, we want errors to show up and not just 'Site not available' # db failure, we want errors to show up and not just 'Site not available'
pass pass
announcements.extend(map(
lambda a: a.serialize(is_mod=is_mod),
db_rows
))
response = { response = {
"status": status, "status": status,
"is_debug": DEBUG_ENABLED, "is_debug": DEBUG_ENABLED,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment