Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Exceptions when saving attachments #106

Open
Cephian opened this issue Apr 2, 2022 · 0 comments
Open

Handle Exceptions when saving attachments #106

Cephian opened this issue Apr 2, 2022 · 0 comments

Comments

@Cephian
Copy link
Collaborator

Cephian commented Apr 2, 2022

Running !list on spotty internet, the download can time out and give an unhandled TimeoutError. We may even want to notify the user in Discord that some files failed to download when the list appears

Interestingly, Nextcord documentation claims that Attachment.save() will only raise either nextcord.HttpException or nextcord.NotFound, so this might be case of lacking documentation on their part as well.

Task exception was never retrieved
future: <Task finished name='Task-45' coro=<scrape_channel_media.<locals>.dl_file() done, defined at /home/jack/Repos/busty/main
Traceback (most recent call last):
  File "/home/jack/Repos/busty/main.py", line 722, in dl_file
    await attachment.save(attachment_filepath)
  File "/home/jack/Repos/busty/env/lib/python3.10/site-packages/nextcord/message.py", line 225, in save
    data = await self.read(use_cached=use_cached)
  File "/home/jack/Repos/busty/env/lib/python3.10/site-packages/nextcord/message.py", line 267, in read
    data = await self._http.get_from_cdn(url)
  File "/home/jack/Repos/busty/env/lib/python3.10/site-packages/nextcord/http.py", line 359, in get_from_cdn
    return await resp.read()
  File "/home/jack/Repos/busty/env/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 1036, in read
    self._body = await self.content.read()
  File "/home/jack/Repos/busty/env/lib/python3.10/site-packages/aiohttp/streams.py", line 375, in read
    block = await self.readany()
  File "/home/jack/Repos/busty/env/lib/python3.10/site-packages/aiohttp/streams.py", line 397, in readany
    await self._wait("readany")
  File "/home/jack/Repos/busty/env/lib/python3.10/site-packages/aiohttp/streams.py", line 303, in _wait
    with self._timer:
  File "/home/jack/Repos/busty/env/lib/python3.10/site-packages/aiohttp/helpers.py", line 721, in __exit__
    raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError
@Cephian Cephian changed the title Handle failed downloads better Handle Exceptions when saving attachments Apr 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant