doobie
doobie copied to clipboard
Introduces attemptSomeSql into ApplicativeErrorOps
Introduces an attemptSomeSql
catcher to partial match on a specific SQLException
.
The use case for it is to match both the stage, but also log the exception itself:
.attemptSomeSql {
case e: PSQLException if SqlState(e.getSQLState) == sqlstate.class23.UNIQUE_VIOLATION =>
logger.error("Database Unique Violation", e)
DbCreateError.UniqueViolation
case e: PSQLException if SqlState(e.getSQLState) == sqlstate.class23.CHECK_VIOLATION =>
logger.error("Database Check Violation", e)
DbCreateError.CheckViolationOnCreate
}
For some reason attemptSomeSql
catcher is mentioned in the docs but not implemented.
Also, I've changed the docker-compose mysql image to not rely on the debian version, as that's not available for arm64 devs