Domain check violations aren't parsed as ConstraintViolations
> conn <- connect defaultConnectInfo
> execute_ conn "CREATE DOMAIN justlower text CHECK ( VALUE ~ '^[a-z]+$');"
> query_ conn "SELECT 'A'::justlower;"
*** Exception: SqlError {sqlState = "23514", sqlExecStatus = FatalError,
sqlErrorMsg = "value for domain justlower violates check constraint \"justlower_check\"",
sqlErrorDetail = "", sqlErrorHint = ""}
The error is 23514, check_violation, but that error code is parsed using parseQ2, expecting two quoted values, as it's usually a table and a column.
I'm not sure how you want to handle this, otherwise we'd make a pull request.
I would like to note that new libpq 9.3+ has all needed fields available in result, so you don't have to parse it (in a hacky way).
If @lpsmith no longer wants to keep this compatible with libpq 9.0 and postgres 8.3+ (or is ok with more CPP) then maybe it's better to integrate that instead.
Argh, libpq versioning stuff really kinda gets me. On the one hand, there are features that I would like to use in newer versions, but I'm also not ready to give up support for libpq 9.0 and postgresql 8.1, and I still haven't figured out how to resolve the contradiction, and thus far the latter concern has won out.
(But, thankfully, there are a lot of things I don't expect to work with postgresql 8.1, such as the typeinfo system. So, because the Errors module is entirely optional, limiting the fix to postgresql 9.0 would be perfectly acceptable to me, and possibly even a newer version.)