Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
don't catch sql error second time
  • Loading branch information
spaced4ndy committed Jul 25, 2025
commit a678758de8d32d24bfa6190b190c90af12794e72
8 changes: 6 additions & 2 deletions src/Simplex/Messaging/Agent/Store/Postgres/DB.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Loading