From 27e4f330a016439c2dd7fb0c938f77d12b02692d Mon Sep 17 00:00:00 2001 From: Aevann Date: Wed, 6 Mar 2024 05:12:36 +0200 Subject: [PATCH] better error message (instead of "/h/None was not found") --- files/helpers/get.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/files/helpers/get.py b/files/helpers/get.py index faca6b714..10b053e1e 100644 --- a/files/helpers/get.py +++ b/files/helpers/get.py @@ -323,18 +323,18 @@ def get_comments_v_properties(v, should_keep_func=None, *criterion): else: dump.append(comment) return (comments, output) -def get_hole(hole, v=None, graceful=False): +def get_hole(hole_name, v=None, graceful=False): + if not hole_name: + if graceful: return None + else: abort(404, f"/h/{hole_name} was not found.") + hole_name = hole_name.replace('/h/', '').replace('h/', '').strip().lower() + if not hole_name: + if graceful: return None + else: abort(404, f"/h/{hole_name} was not found.") + hole = g.db.get(Hole, hole_name) if not hole: if graceful: return None - else: abort(404, f"/h/{hole} was not found.") - hole = hole.replace('/h/', '').replace('h/', '').strip().lower() - if not hole: - if graceful: return None - else: abort(404, f"/h/{hole} was not found.") - hole = g.db.get(Hole, hole) - if not hole: - if graceful: return None - else: abort(404, f"/h/{hole} was not found.") + else: abort(404, f"/h/{hole_name} was not found.") return hole @cache.memoize(timeout=3600)