@@ -14,10 +14,8 @@ module Database.PostgreSQL.Simple.Errors
17−import Prelude hiding (catch)
19import Control.Applicative
17import Control.Applicative
20−import Control.Exception
18+import Control.Exception as E
22import Data.Attoparsec.Char8
20import Data.Attoparsec.Char8
23import Data.ByteString (ByteString)
21import Data.ByteString (ByteString)
@@ -75,7 +73,7 @@ constraintViolation e =
75-- > createUser = catchJust constraintViolationE catcher $ execute conn ...
73-- > createUser = catchJust constraintViolationE catcher $ execute conn ...
77-- > catcher (_, UniqueViolation "user_login_key") = ...
75-- > catcher (_, UniqueViolation "user_login_key") = ...
78−-- > catcher (e, _) = throw e
76+-- > catcher (e, _) = throwIO e
80constraintViolationE :: SqlError -> Maybe (SqlError, ConstraintViolation)
78constraintViolationE :: SqlError -> Maybe (SqlError, ConstraintViolation)
81constraintViolationE e = fmap ((,) e) $ constraintViolation e
79constraintViolationE e = fmap ((,) e) $ constraintViolation e
@@ -86,10 +84,10 @@ constraintViolationE e = fmap ((,) e) $ constraintViolation e
86-- > createUser = catchViolation catcher $ execute conn ...
84-- > createUser = catchViolation catcher $ execute conn ...
88-- > catcher _ (UniqueViolation "user_login_key") = ...
86-- > catcher _ (UniqueViolation "user_login_key") = ...
89−-- > catcher e _ = throw e
87+-- > catcher e _ = throwIO e
90catchViolation :: (SqlError -> ConstraintViolation -> IO a) -> IO a -> IO a
88catchViolation :: (SqlError -> ConstraintViolation -> IO a) -> IO a -> IO a
91−catchViolation f m = catch m
89+catchViolation f m = E.catch m
92− (\e -> maybe (throw e) (f e) $ constraintViolation e)
90+ (\e -> maybe (throwIO e) (f e) $ constraintViolation e)
94-- Parsers just try to extract quoted strings from error messages, number
92-- Parsers just try to extract quoted strings from error messages, number
95-- of quoted strings depend on error type.
93-- of quoted strings depend on error type.