From 5f3320c6cd0737e8f8ee21961f1b8e3ce8c5219c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 10 Sep 2025 16:34:25 +0200 Subject: [PATCH] [exception] update 'AuthRequired' argument handling make the text for 'resource' and 'message' fully optional --- gallery_dl/exception.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gallery_dl/exception.py b/gallery_dl/exception.py index 6adda0d6..559fdd14 100644 --- a/gallery_dl/exception.py +++ b/gallery_dl/exception.py @@ -104,13 +104,16 @@ class AuthRequired(AuthorizationError): if auth: if not isinstance(auth, str): auth = " or ".join(auth) - if " " not in resource: - resource = "this " + resource - if message is None: - message = (f"{auth} needed to access {resource}") + + if resource: + if " " not in resource: + resource = f"this {resource}" + resource = f" to access {resource}" else: - message = (f"{auth} needed to access {resource} " - f"('{message}')") + resource = "" + + message = f" ('{message}')" if message else "" + message = f"{auth} needed{resource}{message}" AuthorizationError.__init__(self, message)