HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulepostgresql-simple-0.7.0.0Haskell2010

Database.PostgreSQL.Simple.Errors

| Module for parsing errors from postgresql error messages. Currently only parses integrity violation errors (class 23).

Note: Success of parsing may depend on language settings.

  • 1 type
  • 6 values
datadata ConstraintViolation
#

Constructors

Instances4Eq, Ord, Show, Exception

Tries to convert SqlError to ConstrainViolation, checks sqlState and succeeds only if able to parse sqlErrorMsg.

createUser = handleJust constraintViolation handler $ execute conn ...
  where
    handler (UniqueViolation "user_login_key") = ...
    handler _ = ...
valuecatchViolation :: (SqlError -> ConstraintViolation -> IO a) -> IO a -> IO a
#

Catches SqlError, tries to convert to ConstraintViolation, re-throws on fail. Provides alternative interface to handleJust

createUser = catchViolation catcher $ execute conn ...
  where
    catcher _ (UniqueViolation "user_login_key") = ...
    catcher e _ = throwIO e