From ad59fa92f1ec3fa0271d7bdaa15adf4f2496c76b Mon Sep 17 00:00:00 2001 From: spiral Date: Wed, 14 Dec 2022 14:47:08 +0000 Subject: [PATCH] feat(bot): ignore a few more database errors --- PluralKit.Bot/Utils/MiscUtils.cs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/PluralKit.Bot/Utils/MiscUtils.cs b/PluralKit.Bot/Utils/MiscUtils.cs index e60ef52e..ee81febc 100644 --- a/PluralKit.Bot/Utils/MiscUtils.cs +++ b/PluralKit.Bot/Utils/MiscUtils.cs @@ -63,15 +63,23 @@ public static class MiscUtils 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 - if (e is PostgresException pe && pe.SqlState == "57P03") return false; + // Ignore "Database is shutting down" error + if (pe.SqlState == "57P03") return false; - // Ignore *other* "database is shutting down" error (57P01) - if (e is PostgresException pe2 && pe2.SqlState == "57P01") return false; + // Ignore *other* "database is shutting down" error (57P01) + if (pe.SqlState == "57P01") return false; - // ignore "out of shared memory" error - if (e is PostgresException pe3 && pe3.SqlState == "53200") return false; + // ignore "out of shared memory" error + if (pe.SqlState == "53200") return false; + + // ignore "too many clients already" error + if (pe.SqlState == "53300") return false; + } // Ignore database timing out as well. if (e is NpgsqlException tpe && tpe.InnerException is TimeoutException)