mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[V3 Sentry] Only log errors that come from core code (#1353)
* Do not load core cogs as extensions * Filter this shit
This commit is contained in:
parent
64af7800dc
commit
10cbd4d3c4
@ -208,8 +208,12 @@ class CogManager:
|
||||
RuntimeError
|
||||
When no matching spec can be found.
|
||||
"""
|
||||
resolved_paths = [str(p.resolve()) for p in await self.paths()]
|
||||
for finder, module_name, _ in pkgutil.iter_modules(resolved_paths):
|
||||
resolved_paths = set(await self.paths())
|
||||
core_paths = set(await self.core_paths())
|
||||
|
||||
real_paths = [str(p) for p in (resolved_paths - core_paths)]
|
||||
|
||||
for finder, module_name, _ in pkgutil.iter_modules(real_paths):
|
||||
if name == module_name:
|
||||
spec = finder.find_spec(name)
|
||||
if spec:
|
||||
|
||||
@ -30,6 +30,21 @@ ______ _ ______ _ _ ______ _
|
||||
"""
|
||||
|
||||
|
||||
def should_log_sentry(exception) -> bool:
|
||||
e = exception
|
||||
while e.__cause__ is not None:
|
||||
e = e.__cause__
|
||||
|
||||
tb = e.__traceback__
|
||||
tb_frame = None
|
||||
while tb is not None:
|
||||
tb_frame = tb.tb_frame
|
||||
tb = tb.tb_next
|
||||
|
||||
module = tb_frame.f_globals.get('__name__')
|
||||
return module.startswith('redbot')
|
||||
|
||||
|
||||
def init_events(bot, cli_flags):
|
||||
|
||||
@bot.event
|
||||
@ -160,9 +175,10 @@ def init_events(bot, cli_flags):
|
||||
log.exception("Exception in command '{}'"
|
||||
"".format(ctx.command.qualified_name),
|
||||
exc_info=error.original)
|
||||
sentry_log.exception("Exception in command '{}'"
|
||||
"".format(ctx.command.qualified_name),
|
||||
exc_info=error.original)
|
||||
if should_log_sentry(error):
|
||||
sentry_log.exception("Exception in command '{}'"
|
||||
"".format(ctx.command.qualified_name),
|
||||
exc_info=error.original)
|
||||
|
||||
message = ("Error in command '{}'. Check your console or "
|
||||
"logs for details."
|
||||
@ -191,8 +207,9 @@ def init_events(bot, cli_flags):
|
||||
except AttributeError:
|
||||
sentry_error = error
|
||||
|
||||
sentry_log.exception("Unhandled command error.",
|
||||
exc_info=sentry_error)
|
||||
if should_log_sentry(sentry_error):
|
||||
sentry_log.exception("Unhandled command error.",
|
||||
exc_info=sentry_error)
|
||||
|
||||
@bot.event
|
||||
async def on_message(message):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user