add check function

This commit is contained in:
Peter McGoron 2021-10-16 13:40:43 -04:00
parent 85acaca0b5
commit af24722b2e
2 changed files with 8 additions and 0 deletions

View File

@ -125,6 +125,10 @@ let finalize = function
Rc.check (S.finalize s); v Rc.check (S.finalize s); v
) )
let check s = match s with
| Failed e -> raise (S.SqliteError (Rc.to_string e))
| Norm (v,_) -> (v,s)
let exec db s = prepare db s () >>$ step let exec db s = prepare db s () >>$ step
let reexec db s = reprepare db s @>$ step let reexec db s = reprepare db s @>$ step
let bsrc l = bind_values l @>$ step @>$ reset @>$ clear_bindings let bsrc l = bind_values l @>$ step @>$ reset @>$ clear_bindings

View File

@ -162,6 +162,10 @@ val finalize : 'a stmt_m -> 'a
(** [finalize] raises an exception if the execution failed, and [V] (** [finalize] raises an exception if the execution failed, and [V]
otherwise. *) otherwise. *)
val check : 'a stmt_m -> ('a * 'a stmt_m)
(** [check] checks if the statement is an error value and throws an
exception if it is. If it is not, then it returns [(V,S)]. *)
val bind_values : Sqlite3.Data.t list -> ('a,'a) monad_fun val bind_values : Sqlite3.Data.t list -> ('a,'a) monad_fun
(** [bind_values l] binds each index of [l] to a positional parameter (** [bind_values l] binds each index of [l] to a positional parameter
in [S]. *) in [S]. *)