mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 11:15:43 -05:00
feat(Error): add Error.result/try_
This commit is contained in:
parent
e73bf4d3e5
commit
88a10dcf3a
2 changed files with 8 additions and 0 deletions
|
|
@ -8,3 +8,7 @@ let () =
|
|||
| _ -> None)
|
||||
|
||||
let errorf msg = Fmt.ksprintf msg ~f:(fun s -> raise (Error s))
|
||||
|
||||
type nonrec 'a result = ('a, string) result
|
||||
|
||||
let try_ f = try Ok (f ()) with Error s -> Error s
|
||||
|
|
|
|||
|
|
@ -2,3 +2,7 @@ exception Error of string
|
|||
|
||||
val errorf : ('a, Format.formatter, unit, 'b) format4 -> 'a
|
||||
(** @raise Error when called *)
|
||||
|
||||
type nonrec 'a result = ('a, string) result
|
||||
|
||||
val try_ : (unit -> 'a) -> 'a result
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue