git.iko.soy/typeable/postgresql-simple
on master help sign in
Merge pull request #203 from supki/fix-examples
5d57651Leon P Smith
src/Database/PostgreSQL/Simple/Errors.hs+7−7
@@ -66,10 +66,10 @@ instance Exception ConstraintViolation
66-- | Tries to convert 'SqlError' to 'ConstrainViolation', checks sqlState and
66-- | Tries to convert 'SqlError' to 'ConstrainViolation', checks sqlState and
67-- succeedes only if able to parse sqlErrorMsg.
67-- succeedes only if able to parse sqlErrorMsg.
68--
68--
69−-- > createUser = catchJust constraintViolation catcher $ execute conn ...
69+-- > createUser = handleJust constraintViolation handler $ execute conn ...
70-- > where
70-- > where
71−-- > catcher UniqueViolation "user_login_key" = ...
71+-- > handler (UniqueViolation "user_login_key") = ...
72−-- > catcher _ = ...
72+-- > handler _ = ...
73constraintViolation :: SqlError -> Maybe ConstraintViolation
73constraintViolation :: SqlError -> Maybe ConstraintViolation
74constraintViolation e =
74constraintViolation e =
75 case sqlState e of
75 case sqlState e of
@@ -84,16 +84,16 @@ constraintViolation e =
84
84
85-- | Like constraintViolation, but also packs original SqlError.
85-- | Like constraintViolation, but also packs original SqlError.
86--
86--
87−-- > createUser = catchJust constraintViolationE catcher $ execute conn ...
87+-- > createUser = handleJust constraintViolationE handler $ execute conn ...
88-- > where
88-- > where
89−-- > catcher (_, UniqueViolation "user_login_key") = ...
89+-- > handler (_, UniqueViolation "user_login_key") = ...
90−-- > catcher (e, _) = throwIO e
90+-- > handler (e, _) = throwIO e
91--
91--
92constraintViolationE :: SqlError -> Maybe (SqlError, ConstraintViolation)
92constraintViolationE :: SqlError -> Maybe (SqlError, ConstraintViolation)
93constraintViolationE e = fmap ((,) e) $ constraintViolation e
93constraintViolationE e = fmap ((,) e) $ constraintViolation e
94
94
95-- | Catches SqlError, tries to convert to ConstraintViolation, re-throws
95-- | Catches SqlError, tries to convert to ConstraintViolation, re-throws
96−-- on fail. Provides alternative interface to catchJust
96+-- on fail. Provides alternative interface to 'E.handleJust'
97--
97--
98-- > createUser = catchViolation catcher $ execute conn ...
98-- > createUser = catchViolation catcher $ execute conn ...
99-- > where
99-- > where