mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
fix(bot): silence internal errors from initial handler checks
This commit is contained in:
parent
e44d2afd7e
commit
8d53021863
2 changed files with 20 additions and 9 deletions
|
|
@ -179,7 +179,7 @@ public class Bot
|
|||
catch (Exception exc)
|
||||
{
|
||||
|
||||
await HandleError(handler, evt, serviceScope, exc);
|
||||
await HandleError(handler, evt, serviceScope, exc, false);
|
||||
}
|
||||
_logger.Verbose("Received gateway event: {@Event}", evt);
|
||||
|
||||
|
|
@ -202,13 +202,13 @@ public class Bot
|
|||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
await HandleError(handler, evt, serviceScope, exc);
|
||||
await HandleError(handler, evt, serviceScope, exc, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleError<T>(IEventHandler<T> handler, T evt, ILifetimeScope serviceScope,
|
||||
Exception exc)
|
||||
public async Task HandleError<T>(IEventHandler<T> handler, T evt, ILifetimeScope serviceScope,
|
||||
Exception exc, bool preChecksDone)
|
||||
where T : IGatewayEvent
|
||||
{
|
||||
_metrics.Measure.Meter.Mark(BotMetrics.BotErrors, exc.GetType().FullName);
|
||||
|
|
@ -245,6 +245,10 @@ public class Bot
|
|||
if (_config.DisableErrorReporting)
|
||||
return;
|
||||
|
||||
// don't show errors for "failed to lookup channel" and such
|
||||
// interaction handler doesn't have pre-checks, so just always try to show
|
||||
if (!(preChecksDone && !(evt is InteractionCreateEvent _))) return;
|
||||
|
||||
if (!exc.ShowToUser()) return;
|
||||
|
||||
// Once we've sent it to Sentry, report it to the user (if we have permission to)
|
||||
|
|
|
|||
|
|
@ -86,12 +86,19 @@ public class MessageCreated: IEventHandler<MessageCreateEvent>
|
|||
}
|
||||
|
||||
// Try each handler until we find one that succeeds
|
||||
// only show exceptions to users if the checks above succeed
|
||||
try
|
||||
{
|
||||
if (await TryHandleCommand(shardId, evt, guild, channel))
|
||||
return;
|
||||
|
||||
if (await TryHandleCommand(shardId, evt, guild, channel))
|
||||
return;
|
||||
|
||||
if (evt.GuildId != null)
|
||||
await TryHandleProxy(evt, guild, channel, rootChannel.Id, botPermissions);
|
||||
if (evt.GuildId != null)
|
||||
await TryHandleProxy(evt, guild, channel, rootChannel.Id, botPermissions);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
await _bot.HandleError(this, evt, _services, exc, true);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task TryHandleLogClean(Channel channel, MessageCreateEvent evt)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue