Skip to content

Commit

Permalink
refactor: Log error with hint about possibly too big torrent when add…
Browse files Browse the repository at this point in the history
…ing it fails with a connection error

Issue-130: #130
  • Loading branch information
pawamoy committed Nov 26, 2024
1 parent 0f112c3 commit 77d9fca
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/aria2p/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from typing import TYPE_CHECKING, Callable, TextIO, Union

from loguru import logger
from requests.exceptions import ConnectionError # noqa: A004

from aria2p.client import Client, ClientException
from aria2p.downloads import Download
Expand Down Expand Up @@ -152,7 +153,11 @@ def add_torrent(
torrent_contents = stream.read()
encoded_contents = b64encode(torrent_contents).decode("utf8")

gid = self.client.add_torrent(encoded_contents, uris, client_options, position)
try:
gid = self.client.add_torrent(encoded_contents, uris, client_options, position)
except ConnectionError:
logger.error("Torrent too big? Try increasing max size with aria2c's --rpc-max-request-size option")
raise

return self.get_download(gid)

Expand Down

0 comments on commit 77d9fca

Please sign in to comment.