doobie icon indicating copy to clipboard operation
doobie copied to clipboard

Introduces attemptSomeSql into ApplicativeErrorOps

Open prascuna opened this issue 5 months ago • 4 comments

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

prascuna avatar Aug 27 '24 14:08 prascuna