From a678758de8d32d24bfa6190b190c90af12794e72 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Fri, 25 Jul 2025 12:42:50 +0400 Subject: [PATCH] don't catch sql error second time --- src/Simplex/Messaging/Agent/Store/Postgres/DB.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Simplex/Messaging/Agent/Store/Postgres/DB.hs b/src/Simplex/Messaging/Agent/Store/Postgres/DB.hs index f58f9472f..8c49f5098 100644 --- a/src/Simplex/Messaging/Agent/Store/Postgres/DB.hs +++ b/src/Simplex/Messaging/Agent/Store/Postgres/DB.hs @@ -18,7 +18,6 @@ module Simplex.Messaging.Agent.Store.Postgres.DB ) where -import Control.Exception (catch) import qualified Control.Exception as E import Control.Monad (void) import Data.ByteString.Char8 (ByteString) @@ -68,7 +67,12 @@ withLoggedErrors :: Show q => q -> IO a -> IO a withLoggedErrors q action = action `E.catch` (\(e :: SqlError) -> logSqlErrorAndRethrow e) - `E.catch` (\(e :: E.SomeException) -> logGenericErrorAndRethrow e) + `E.catch` + (\(e :: E.SomeException) -> + case E.fromException e :: Maybe SqlError of + Just sqlErr -> E.throwIO sqlErr -- rethrow SqlError without logging + Nothing -> logGenericErrorAndRethrow e + ) where logSqlErrorAndRethrow :: SqlError -> IO a logSqlErrorAndRethrow e = do