feat(bot): don't send internal error messages for some errors that should be on sentry
This commit is contained in:
parent
026a822c74
commit
2602763e25
@ -231,6 +231,8 @@ public class Bot
|
|||||||
if (_config.DisableErrorReporting)
|
if (_config.DisableErrorReporting)
|
||||||
return;
|
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)
|
||||||
var reportChannel = handler.ErrorChannelFor(evt, _config.ClientId);
|
var reportChannel = handler.ErrorChannelFor(evt, _config.ClientId);
|
||||||
if (reportChannel == null)
|
if (reportChannel == null)
|
||||||
|
@ -57,6 +57,13 @@ public static class MiscUtils
|
|||||||
// HTTP/2 streams are complicated and break sometimes.
|
// HTTP/2 streams are complicated and break sometimes.
|
||||||
if (e is HttpRequestException) return false;
|
if (e is HttpRequestException) return false;
|
||||||
|
|
||||||
|
// This may expanded at some point.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ShowToUser(this Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
// Ignore "Database is shutting down" error
|
// Ignore "Database is shutting down" error
|
||||||
if (e is PostgresException pe && pe.SqlState == "57P03") return false;
|
if (e is PostgresException pe && pe.SqlState == "57P03") return false;
|
||||||
|
|
||||||
@ -71,7 +78,10 @@ public static class MiscUtils
|
|||||||
if (e is NpgsqlException npe && npe.Message.Contains("The connection pool has been exhausted"))
|
if (e is NpgsqlException npe && npe.Message.Contains("The connection pool has been exhausted"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// This may expanded at some point.
|
// ignore "Exception while reading from stream"
|
||||||
|
if (e is NpgsqlException npe2 && npe2.Message.Contains("Exception while reading from stream"))
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user