Skip to content

Commit

Permalink
Adds Error handling section to the sections list
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscodr committed Aug 8, 2016
1 parent 5cc598f commit c7da1e1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/main/scala/doobie/DoobieLibrary.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ object DoobieLibrary extends Library {
SelectingDataSection,
MultiColumnQueriesSection,
ParameterizedQueriesSection,
UpdatesSection
UpdatesSection,
ErrorHandlingSection
)
}
34 changes: 17 additions & 17 deletions src/main/scala/doobie/ErrorHandlingSection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import scalaz.\/
* provided interpreter requires all target monads to have an instance as well. `Catchable`
* provides two operations:
*
* - `attempt` converts `M[A]` into `M[Throwable \/ A]`
* - `fail` constructs an `M[A]` that fails with a provided `Throwable`
* - `attempt` converts `M[A]` into `M[Throwable \/ A]`
* - `fail` constructs an `M[A]` that fails with a provided `Throwable`
*
* So any '''doobie''' program can be lifted into a disjunction simply by adding `.attempt`.
*
Expand All @@ -34,25 +34,25 @@ import scalaz.\/
*
* From the `.attempt` combinator we derive the following, available as combinators and as syntax:
*
* - `attemptSome` allows you to catch only specified `Throwable`s.
* - `except` recovers with a new action.
* - `exceptSome` same, but only for specified `Throwable`s.
* - `onException` executes an action on failure, discarding its result.
* - `ensuring` executes an action in all cases, generalizing `finally`.
* - `attemptSome` allows you to catch only specified `Throwable`s.
* - `except` recovers with a new action.
* - `exceptSome` same, but only for specified `Throwable`s.
* - `onException` executes an action on failure, discarding its result.
* - `ensuring` executes an action in all cases, generalizing `finally`.
*
* From these we can derive combinators that only pay attention to `SQLException`:
*
* - `attemptSql` is like `attempt` but only traps `SQLException`.
* - `attemptSomeSql` traps only specified `SQLException`s.
* - `exceptSql` recovers from a SQLException with a new action.
* - `onSqlException` executes an action on `SQLException` and discards its result.
* - `attemptSql` is like `attempt` but only traps `SQLException`.
* - `attemptSomeSql` traps only specified `SQLException`s.
* - `exceptSql` recovers from a SQLException with a new action.
* - `onSqlException` executes an action on `SQLException` and discards its result.
*
* And finally we have a set of combinators that focus on SQLStates.
*
* - `attemptSqlState` is like `attemptSql` but yields `M[SQLState \/ A]`.
* - `attemptSomeSqlState` traps only specified `SQLState`s.
* - `exceptSqlState` recovers from a `SQLState` with a new action.
* - `exceptSomeSqlState` recovers from specified `SQLState`s with a new action.
* - `attemptSqlState` is like `attemptSql` but yields `M[SQLState \/ A]`.
* - `attemptSomeSqlState` traps only specified `SQLState`s.
* - `exceptSqlState` recovers from a `SQLState` with a new action.
* - `exceptSomeSqlState` recovers from specified `SQLState`s with a new action.
*
* @param name error_handling
*/
Expand Down Expand Up @@ -112,8 +112,8 @@ object ErrorHandlingSection extends FlatSpec with Matchers with Section {
* `attemptSomeSqlState`. We can specify several `SqlState` values and indicate what value we'll
* return in each case. We can:
*
* - Use the `SqlState` values provided as constants in the contrib-postgresql add-on
* - Create a new `SqlState` value by typing `val UNIQUE_VIOLATION = SqlState("23505")`
* - Use the `SqlState` values provided as constants in the contrib-postgresql add-on
* - Create a new `SqlState` value by typing `val UNIQUE_VIOLATION = SqlState("23505")`
*/
def safeInsertWithAttemptSomeSqlState(res0: String \/ Long) = {

Expand Down

0 comments on commit c7da1e1

Please # to comment.