on dev help sign in
trySqueal
commita8ab4b4919076fede5c9bcfc03ceaee0f7232bee authorEitan Chatav <eitan@Eitans-MacBook-Pro.local> dateMon 17 Jun 2019, 21:58 (7 years ago) parent0bbc43b
1 file changed+9−1
squeal-postgresql/src/Squeal/PostgreSQL/PQ.hs+9−1
squeal-postgresql/src/Squeal/PostgreSQL/PQ.hs+9−1
@@ -68,12 +68,13 @@ module Squeal.PostgreSQL.PQ
6868 , okResult
6969 , catchSqueal
7070 , handleSqueal
71+ , trySqueal
7172 ) where
7273
7374import Control.Exception (Exception, throw)
7475import Control.Monad.Except
7576import Control.Monad.Morph
76−import UnliftIO (MonadUnliftIO (..), bracket, catch, handle)
77+import UnliftIO (MonadUnliftIO (..), bracket, catch, handle, try)
7778import Data.ByteString (ByteString)
7879import Data.Foldable
7980import Data.Function ((&))
@@ -678,3 +679,10 @@ handleSqueal
678679 => (SquealException -> io a) -- ^ handler
679680 -> io a -> io a
680681handleSqueal = handle
682+
683+-- | `Either` return a `SquealException` or a result.
684+trySqueal
685+ :: MonadUnliftIO io
686+ => io a
687+ -> io (Either SquealException a)
688+trySqueal = try