From 56eaa8a793e5ab3ca5a26125190b8327444e268f Mon Sep 17 00:00:00 2001 From: krateng Date: Thu, 9 Dec 2021 19:49:53 +0100 Subject: [PATCH] Error handling details --- maloja/database.py | 8 +++++--- maloja/server.py | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/maloja/database.py b/maloja/database.py index 1177a14..a1b83fc 100644 --- a/maloja/database.py +++ b/maloja/database.py @@ -51,9 +51,11 @@ dbstatus = { } class DatabaseNotBuilt(HTTPError): def __init__(self): - super().__init__() - self.status = 503 - self.body = "The Maloja Database is still being built. Try again in a few seconds." + super().__init__( + status=503, + body="The Maloja Database is still being built. Try again in a few seconds.", + headers={"Retry-After":10} + ) SCROBBLES = [] # Format: tuple(track_ref,timestamp,saved) ARTISTS = [] # Format: artist diff --git a/maloja/server.py b/maloja/server.py index cdbe040..2ef15e8 100644 --- a/maloja/server.py +++ b/maloja/server.py @@ -270,8 +270,8 @@ def register_endpoints_web_dynamic(): template = jinja_environment.get_template(name + '.jinja') try: res = template.render(**LOCAL_CONTEXT) - except ValueError as e: - abort(404,"Entity does not exist") + except (ValueError, IndexError) as e: + abort(404,"This Artist or Track does not exist") if settings.get_settings("DEV_MODE"): jinja_environment.cache.clear()