Skip to content

Commit 8b4562c

Browse files
committed
HasCallStack
1 parent 3f67a93 commit 8b4562c

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/Database/PostgreSQL/PQTypes/Internal/State.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ withConnection ConnectionData {..} action = do
189189
Finalized -> error "finalized connection"
190190

191191
initConnectionData
192-
:: (MonadBase IO m, MonadMask m)
192+
:: MonadBase IO m
193193
=> ConnectionSourceM m
194194
-> ConnectionAcquisitionMode
195195
-> m (ConnectionData m)

src/Database/PostgreSQL/PQTypes/Internal/Utils.hs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import Foreign.Marshal.Utils
2929
import Foreign.Ptr
3030
import Foreign.Storable
3131
import GHC.Exts
32+
import GHC.Stack
3233

3334
import Database.PostgreSQL.PQTypes.Internal.C.Interface
3435
import Database.PostgreSQL.PQTypes.Internal.C.Types
@@ -82,12 +83,12 @@ textToCString bs = unsafeUseAsCStringLen (T.encodeUtf8 bs) $ \(cs, len) -> do
8283

8384
-- | Check return value of a function from libpqtypes
8485
-- and if it indicates an error, throw appropriate exception.
85-
verifyPQTRes :: Ptr PGerror -> String -> CInt -> IO ()
86+
verifyPQTRes :: HasCallStack => Ptr PGerror -> String -> CInt -> IO ()
8687
verifyPQTRes err ctx 0 = throwLibPQTypesError err ctx
8788
verifyPQTRes _ _ _ = pure ()
8889

8990
-- 'alloca'-like function for managing usage of 'PGparam' object.
90-
withPGparam :: Ptr PGconn -> (Ptr PGparam -> IO r) -> IO r
91+
withPGparam :: HasCallStack => Ptr PGconn -> (Ptr PGparam -> IO r) -> IO r
9192
withPGparam conn = E.bracket create c_PQparamClear
9293
where
9394
create = alloca $ \err -> do
@@ -99,21 +100,21 @@ withPGparam conn = E.bracket create c_PQparamClear
99100
----------------------------------------
100101

101102
-- | Throw libpq specific error.
102-
throwLibPQError :: Ptr PGconn -> String -> IO a
103+
throwLibPQError :: HasCallStack => Ptr PGconn -> String -> IO a
103104
throwLibPQError conn ctx = do
104105
msg <- safePeekCString' =<< c_PQerrorMessage conn
105106
E.throwIO . LibPQError $
106107
if null ctx then msg else ctx ++ ": " ++ msg
107108

108109
-- | Throw libpqtypes specific error.
109-
throwLibPQTypesError :: Ptr PGerror -> String -> IO a
110+
throwLibPQTypesError :: HasCallStack => Ptr PGerror -> String -> IO a
110111
throwLibPQTypesError err ctx = do
111112
msg <- pgErrorMsg <$> peek err
112113
E.throwIO . LibPQError $
113114
if null ctx then msg else ctx ++ ": " ++ msg
114115

115116
-- | Rethrow supplied exception enriched with array index.
116-
rethrowWithArrayError :: CInt -> E.SomeException -> IO a
117+
rethrowWithArrayError :: HasCallStack => CInt -> E.SomeException -> IO a
117118
rethrowWithArrayError i (E.SomeException e) =
118119
E.throwIO
119120
ArrayItemError
@@ -122,9 +123,9 @@ rethrowWithArrayError i (E.SomeException e) =
122123
}
123124

124125
-- | Throw 'HPQTypesError exception.
125-
hpqTypesError :: String -> IO a
126+
hpqTypesError :: HasCallStack => String -> IO a
126127
hpqTypesError = E.throwIO . HPQTypesError
127128

128129
-- | Throw 'unexpected NULL' exception.
129-
unexpectedNULL :: IO a
130+
unexpectedNULL :: HasCallStack => IO a
130131
unexpectedNULL = hpqTypesError "unexpected NULL"

0 commit comments

Comments
 (0)