Stop logging "returning exception"
Lonami opened this issue · 2 comments
Every time an exception occurs, the following line is logged if logging
is enabled:
Lines 98 to 99 in 55558d4
This is bad because the library can and does propagate the error:
Line 100 in 55558d4
The user code will handle it, there is no need to log it unless the library could not pass it to the user's code. If the user code wants to log it, that's their job. Maybe the INFO
level would be more appropriated "hey, an error occured and I am informing that I will hand it over to user's code". Not ERROR
, it works fine!
In my use case I am doing this:
try:
tup = await db.execute("SELECT * FROM Version")
except sqlite3.OperationalError:
await create_tables(db)
I try to select from the version table, and if said table is missing I ask for forgiveness by except
ing the error. This behaviour is correct, but aiosqlite
is logging an error that shouldn't.
I got fed up with these logs when I am using sqlite3 correctly and handling expected errors like uniqueness constraints inside my application. Unfortunately, my only temporary solution was to tell aiosqlite logging to get bent. I would like to not do this and will follow this issue for a better resolution.
Edit: removed my hack solution; thanks for fixing this!