doobie.syntax.catchsql.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of doobie-core-cats_2.11 Show documentation
Show all versions of doobie-core-cats_2.11 Show documentation
Pure functional JDBC layer for Scala.
The newest version!
package doobie.syntax
import doobie.util.{ catchsql => C }
import scala.util.{ Either => \/ }
import fs2.util.Catchable
import doobie.enum.sqlstate.SqlState
import java.sql.SQLException
/** Syntax for `Catchable` combinators defined in `util.catchsql`. */
object catchsql {
class DoobieCatchSqlOps[M[_]: Catchable, A](self: M[A]) {
def attemptSql: M[SQLException \/ A] =
C.attemptSql(self)
def attemptSqlState: M[SqlState \/ A] =
C.attemptSqlState(self)
def attemptSomeSqlState[B](f: PartialFunction[SqlState, B]): M[B \/ A] =
C.attemptSomeSqlState(self)(f)
def exceptSql(handler: SQLException => M[A]): M[A] =
C.exceptSql(self)(handler)
def exceptSqlState(handler: SqlState => M[A]): M[A] =
C.exceptSqlState(self)(handler)
def exceptSomeSqlState(pf: PartialFunction[SqlState, M[A]]): M[A] =
C.exceptSomeSqlState(self)(pf)
def onSqlException[B](action: M[B]): M[A] =
C.onSqlException(self)(action)
}
trait ToDoobieCatchSqlOps {
/** @group Syntax */
implicit def toDoobieCatchSqlOps[M[_]: Catchable, A](ma: M[A]): DoobieCatchSqlOps[M, A] =
new DoobieCatchSqlOps(ma)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy