add result.ml; polymorphic variant errors + refacto
This commit is contained in:
parent
9fd3b5a3cc
commit
42b0ec1445
36 changed files with 949 additions and 954 deletions
11
src/bbin.ml
Normal file
11
src/bbin.ml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
let encode bin t =
|
||||
try Ok (Bin.to_string bin t)
|
||||
with Invalid_argument e ->
|
||||
Fmt.error "Bin encode error %s" e
|
||||
|> Result.map_error (fun e -> `Bin_encode e)
|
||||
|
||||
let decode bin o =
|
||||
try Ok (Bin.decode bin o (ref 0))
|
||||
with Invalid_argument e ->
|
||||
Fmt.error "Bin decode error %s" e
|
||||
|> Result.map_error (fun e -> `Bin_decode e)
|
||||
Loading…
Add table
Add a link
Reference in a new issue