I've seen mentioned in many posts on Stack Overflow that discord.py "hides errors" by default, if logging is not configured. In the docs, it is mentioned that:
It is strongly recommended that the logging module is configured, as no errors or warnings will be output if it is not set up. [emphasis mine]
However, in discord.py 1.7.3, I observed that errors are outputted to the console. Running the following code snippet:
import discord
client = discord.Client(intents=discord.Intents.all())
@client.event
async def on_ready():
raise ValueError
client.run(TOKEN)
properly raises a ValueError
- the error is not swallowed.
In discord.py 2.0, logging is already set up, as evidenced by the output (with the same code snippet):
[2022-07-15 12:28:40] [INFO ] discord.client: logging in using static token
[2022-07-15 12:28:41] [INFO ] discord.gateway: Shard ID None has sent the IDENTIFY payload.
[2022-07-15 12:28:41] [INFO ] discord.gateway: Shard ID None has connected to Gateway (Session ID: ...).
[2022-07-15 12:28:43] [ERROR ] discord.client: Ignoring exception in on_ready
# ^-----------------^ These lines are all from the logging module
Traceback (most recent call last):
File "C:\Users\TheFu\PycharmProjects\mcve2.0\venv\lib\site-packages\discord\client.py", line 456, in _run_event
await coro(*args, **kwargs)
File "C:\Users\TheFu\PycharmProjects\mcve2.0\main.py", line 8, in on_ready
raise ValueError
ValueError
So, if logging hasn't been set up in discord.py 1.7.3, why is an error outputted? What errors do get swallowed in this version?
No comments:
Post a Comment