Skip to content

Commit 5d57651

Browse files
authored
Merge pull request #203 from supki/fix-examples
Fix the exception handling examples.
2 parents a8f6a90 + 3c01492 commit 5d57651

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/Database/PostgreSQL/Simple/Errors.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ instance Exception ConstraintViolation
6666
-- | Tries to convert 'SqlError' to 'ConstrainViolation', checks sqlState and
6767
-- succeedes only if able to parse sqlErrorMsg.
6868
--
69-
-- > createUser = catchJust constraintViolation catcher $ execute conn ...
69+
-- > createUser = handleJust constraintViolation handler $ execute conn ...
7070
-- > where
71-
-- > catcher UniqueViolation "user_login_key" = ...
72-
-- > catcher _ = ...
71+
-- > handler (UniqueViolation "user_login_key") = ...
72+
-- > handler _ = ...
7373
constraintViolation :: SqlError -> Maybe ConstraintViolation
7474
constraintViolation e =
7575
case sqlState e of
@@ -84,16 +84,16 @@ constraintViolation e =
8484

8585
-- | Like constraintViolation, but also packs original SqlError.
8686
--
87-
-- > createUser = catchJust constraintViolationE catcher $ execute conn ...
87+
-- > createUser = handleJust constraintViolationE handler $ execute conn ...
8888
-- > where
89-
-- > catcher (_, UniqueViolation "user_login_key") = ...
90-
-- > catcher (e, _) = throwIO e
89+
-- > handler (_, UniqueViolation "user_login_key") = ...
90+
-- > handler (e, _) = throwIO e
9191
--
9292
constraintViolationE :: SqlError -> Maybe (SqlError, ConstraintViolation)
9393
constraintViolationE e = fmap ((,) e) $ constraintViolation e
9494

9595
-- | 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'
9797
--
9898
-- > createUser = catchViolation catcher $ execute conn ...
9999
-- > where

0 commit comments

Comments
 (0)