git.iko.soy/typeable/postgresql-simple
on master help sign in
Fix the exception handling examples.
commit3c014924735ad564b53072996dc7aa7050761444 authorMatvey Aksenov <matvey.aksenov@gmail.com> dateTue 14 Feb 2017, 18:38 (10 years ago) parenta8f6a90
1 file changed+7−7
src/Database/PostgreSQL/Simple/Errors.hs+7−7
src/Database/PostgreSQL/Simple/Errors.hs+7−7
@@ -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 _ = ...
7373constraintViolation :: SqlError -> Maybe ConstraintViolation
7474constraintViolation 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--
9292constraintViolationE :: SqlError -> Maybe (SqlError, ConstraintViolation)
9393constraintViolationE 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