server/net: return more useful error messages
This commit is contained in:
parent
c3b81371d8
commit
ad9d3599bc
1 changed files with 11 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue