summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/szurubooru/func/net.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/server/szurubooru/func/net.py b/server/szurubooru/func/net.py
index 9dff3c4..3f085a0 100644
--- a/server/szurubooru/func/net.py
+++ b/server/szurubooru/func/net.py
@@ -42,10 +42,17 @@ def download(url: str, use_video_downloader: bool = False) -> bytes:
while (chunk := handle.read(_dl_chunk_size)) :
length_tally += len(chunk)
if length_tally > config.config["max_dl_filesize"]:
- raise DownloadTooLargeError(url)
+ raise DownloadTooLargeError(
+ "Download target exceeds maximum. (%d)"
+ % (config.config["max_dl_filesize"]),
+ extra_fields={"URL": url},
+ )
content_buffer += chunk
except urllib.error.HTTPError as ex:
- raise DownloadError(url) from ex
+ raise DownloadError(
+ "Download target returned HTTP %d. (%s)" % (ex.code, ex.reason),
+ extra_fields={"URL": url},
+ ) from ex
if (
youtube_dl_error
@@ -69,7 +76,8 @@ def _get_youtube_dl_content_url(url: str) -> str:
)
except subprocess.CalledProcessError:
raise errors.ThirdPartyError(
- "Could not extract content location from %s" % (url)
+ "Could not extract content location from URL.",
+ extra_fields={"URL": url},
) from None