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)
|
catch (Exception exc)
|
||||||
{
|
{
|
||||||
|
|
||||||
await HandleError(handler, evt, serviceScope, exc);
|
await HandleError(handler, evt, serviceScope, exc, false);
|
||||||
}
|
}
|
||||||
_logger.Verbose("Received gateway event: {@Event}", evt);
|
_logger.Verbose("Received gateway event: {@Event}", evt);
|
||||||
|
|
||||||
|
|
@ -202,13 +202,13 @@ public class Bot
|
||||||
}
|
}
|
||||||
catch (Exception exc)
|
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,
|
public async Task HandleError<T>(IEventHandler<T> handler, T evt, ILifetimeScope serviceScope,
|
||||||
Exception exc)
|
Exception exc, bool preChecksDone)
|
||||||
where T : IGatewayEvent
|
where T : IGatewayEvent
|
||||||
{
|
{
|
||||||
_metrics.Measure.Meter.Mark(BotMetrics.BotErrors, exc.GetType().FullName);
|
_metrics.Measure.Meter.Mark(BotMetrics.BotErrors, exc.GetType().FullName);
|
||||||
|
|
@ -245,6 +245,10 @@ public class Bot
|
||||||
if (_config.DisableErrorReporting)
|
if (_config.DisableErrorReporting)
|
||||||
return;
|
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;
|
if (!exc.ShowToUser()) return;
|
||||||
|
|
||||||
// Once we've sent it to Sentry, report it to the user (if we have permission to)
|
// 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
|
// 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))
|
if (evt.GuildId != null)
|
||||||
return;
|
await TryHandleProxy(evt, guild, channel, rootChannel.Id, botPermissions);
|
||||||
|
}
|
||||||
if (evt.GuildId != null)
|
catch (Exception exc)
|
||||||
await TryHandleProxy(evt, guild, channel, rootChannel.Id, botPermissions);
|
{
|
||||||
|
await _bot.HandleError(this, evt, _services, exc, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task TryHandleLogClean(Channel channel, MessageCreateEvent evt)
|
private async Task TryHandleLogClean(Channel channel, MessageCreateEvent evt)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue