From f7aa7d8dfd8d0a34ce4e8a945d4515ea4e59f0cc Mon Sep 17 00:00:00 2001 From: Aevann Date: Wed, 28 Dec 2022 11:50:48 +0200 Subject: [PATCH] better error messages --- files/routes/admin.py | 2 +- files/routes/posts.py | 5 +++-- files/routes/reporting.py | 3 ++- files/routes/users.py | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/files/routes/admin.py b/files/routes/admin.py index 2a80c9b92..26e533e88 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1534,7 +1534,7 @@ def admin_banned_domains(v): # reason = filter_emojis_only(reason) # if len(reason) > 100: -# abort(400, 'Reason is too long (max 100 characters)!') +# abort(400, 'Reason is too long!') # existing = g.db.get(BannedDomain, domain) # if not existing: diff --git a/files/routes/posts.py b/files/routes/posts.py index a997e86c7..565ac3630 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -321,7 +321,7 @@ def edit_post(pid, v): if not execute_blackjack(v, p, text, 'submission'): break if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT: - abort(400, f"Submission body_html too long! (max {POST_BODY_HTML_LENGTH_LIMIT} characters)") + abort(400, f"Submission body_html too long!") p.body_html = body_html @@ -688,7 +688,8 @@ def submit_post(v:User, sub=None): if v.marseyawarded and marseyaward_body_regex.search(body_html): return error("You can only type marseys!") - if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT: return error(f"Submission body_html too long! (max {POST_BODY_HTML_LENGTH_LIMIT} characters)") + if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT: + return error(f"Submission body_html too long!") flag_notify = (request.values.get("notify", "on") == "on") flag_new = request.values.get("new", False, bool) or 'megathread' in title.lower() diff --git a/files/routes/reporting.py b/files/routes/reporting.py index 7a66b90a4..4f565c363 100644 --- a/files/routes/reporting.py +++ b/files/routes/reporting.py @@ -24,7 +24,8 @@ def flag_post(pid, v): reason = reason[:100] og_flair = reason[1:] reason = filter_emojis_only(reason) - if len(reason) > 350: abort(400, "Too long.") + if len(reason) > 350: + abort(400, "Report reason too long!") if reason.startswith('!') and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or post.sub and v.mods(post.sub)): post.flair = reason[1:] diff --git a/files/routes/users.py b/files/routes/users.py index fd178d898..964093590 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -320,7 +320,8 @@ def transfer_currency(v:User, username:str, currency_name:Literal['coins', 'mars notif_text = f":marseycapitalistmanlet: @{v.username} has gifted you {amount-tax} {currency_name}!" if reason: - if len(reason) > TRANSFER_MESSAGE_LENGTH_LIMIT: abort(400, f"Reason is too long, max {TRANSFER_MESSAGE_LENGTH_LIMIT} characters") + if len(reason) > TRANSFER_MESSAGE_LENGTH_LIMIT: + abort(400, f"Reason is too long, max {TRANSFER_MESSAGE_LENGTH_LIMIT} characters") notif_text += f"\n\n> {reason}" log_message += f"\n\n> {reason}"