feat(bot): ignore a few more database errors

This commit is contained in:
spiral 2022-12-14 14:47:08 +00:00
parent f77308f344
commit ad59fa92f1
No known key found for this signature in database
GPG Key ID: 244A11E4B0BCF40E

View File

@ -63,15 +63,23 @@ public static class MiscUtils
public static bool ShowToUser(this Exception e) public static bool ShowToUser(this Exception e)
{ {
if (e is PostgresException pe)
{
// ignore "cached plan must not change result type" error
if (pe.SqlState == "0A000") return false;
// Ignore "Database is shutting down" error // Ignore "Database is shutting down" error
if (e is PostgresException pe && pe.SqlState == "57P03") return false; if (pe.SqlState == "57P03") return false;
// Ignore *other* "database is shutting down" error (57P01) // Ignore *other* "database is shutting down" error (57P01)
if (e is PostgresException pe2 && pe2.SqlState == "57P01") return false; if (pe.SqlState == "57P01") return false;
// ignore "out of shared memory" error // ignore "out of shared memory" error
if (e is PostgresException pe3 && pe3.SqlState == "53200") return false; if (pe.SqlState == "53200") return false;
// ignore "too many clients already" error
if (pe.SqlState == "53300") return false;
}
// Ignore database timing out as well. // Ignore database timing out as well.
if (e is NpgsqlException tpe && tpe.InnerException is TimeoutException) if (e is NpgsqlException tpe && tpe.InnerException is TimeoutException)