mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -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
|
RuntimeError
|
||||||
When no matching spec can be found.
|
When no matching spec can be found.
|
||||||
"""
|
"""
|
||||||
resolved_paths = [str(p.resolve()) for p in await self.paths()]
|
resolved_paths = set(await self.paths())
|
||||||
for finder, module_name, _ in pkgutil.iter_modules(resolved_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:
|
if name == module_name:
|
||||||
spec = finder.find_spec(name)
|
spec = finder.find_spec(name)
|
||||||
if spec:
|
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):
|
def init_events(bot, cli_flags):
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
@ -160,6 +175,7 @@ def init_events(bot, cli_flags):
|
|||||||
log.exception("Exception in command '{}'"
|
log.exception("Exception in command '{}'"
|
||||||
"".format(ctx.command.qualified_name),
|
"".format(ctx.command.qualified_name),
|
||||||
exc_info=error.original)
|
exc_info=error.original)
|
||||||
|
if should_log_sentry(error):
|
||||||
sentry_log.exception("Exception in command '{}'"
|
sentry_log.exception("Exception in command '{}'"
|
||||||
"".format(ctx.command.qualified_name),
|
"".format(ctx.command.qualified_name),
|
||||||
exc_info=error.original)
|
exc_info=error.original)
|
||||||
@ -191,6 +207,7 @@ def init_events(bot, cli_flags):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
sentry_error = error
|
sentry_error = error
|
||||||
|
|
||||||
|
if should_log_sentry(sentry_error):
|
||||||
sentry_log.exception("Unhandled command error.",
|
sentry_log.exception("Unhandled command error.",
|
||||||
exc_info=sentry_error)
|
exc_info=sentry_error)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user