Skip to content

Commit 77d9fca

Browse files
committed
refactor: Log error with hint about possibly too big torrent when adding it fails with a connection error
Issue-130: #130
1 parent 0f112c3 commit 77d9fca

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/aria2p/api.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from typing import TYPE_CHECKING, Callable, TextIO, Union
1515

1616
from loguru import logger
17+
from requests.exceptions import ConnectionError # noqa: A004
1718

1819
from aria2p.client import Client, ClientException
1920
from aria2p.downloads import Download
@@ -152,7 +153,11 @@ def add_torrent(
152153
torrent_contents = stream.read()
153154
encoded_contents = b64encode(torrent_contents).decode("utf8")
154155

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

157162
return self.get_download(gid)
158163

0 commit comments

Comments
 (0)