summaryrefslogtreecommitdiff
path: root/lib/kDL.ml
diff options
context:
space:
mode:
authortoastal2026-04-15 01:49:13 +0000
committerยท๐‘‘๐‘ด๐‘•๐‘‘๐‘ฉ๐‘ค2026-04-15 01:49:13 +0000
commit47363e258f3e3f916cfe592e5de3bbe63bc16f84 (patch)
tree0c1d37439505aa742bba112518416d54878138f4 /lib/kDL.ml
parent9b65a20925349dbdc5919041d81cbd12ad8facf1 (diff)
downloadnixtaml-47363e258f3e3f916cfe592e5de3bbe63bc16f84.tar
nixtaml-47363e258f3e3f916cfe592e5de3bbe63bc16f84.tar.gz
nixtaml-47363e258f3e3f916cfe592e5de3bbe63bc16f84.tar.bz2
nixtaml-47363e258f3e3f916cfe592e5de3bbe63bc16f84.tar.lz
nixtaml-47363e258f3e3f916cfe592e5de3bbe63bc16f84.tar.xz
nixtaml-47363e258f3e3f916cfe592e5de3bbe63bc16f84.tar.zst
nixtaml-47363e258f3e3f916cfe592e5de3bbe63bc16f84.zip
Fix KDL.of_flow Result type and update callers
- Properly type annotate KDL.of_flow to return (t, [> `ParseError]) result - Handle nested Results from Eio.Buf_read.parse_exn - Fix Manifest.read to work with new Result type - Fix nixtamal.ml error handling for Manifest and Lockfile errors All 17 tests pass.
Diffstat (limited to 'lib/kDL.ml')
-rw-r--r--lib/kDL.ml8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/kDL.ml b/lib/kDL.ml
index a00d1ff..5f94557 100644
--- a/lib/kDL.ml
+++ b/lib/kDL.ml
@@ -5,13 +5,15 @@
(* extend & fix casing for ocaml-kdl *)
include Kdl
-let of_flow flow =
+let of_flow flow : (t, [> `ParseError of string]) result =
try
- Eio.Buf_read.parse_exn
+ match Eio.Buf_read.parse_exn
(fun buf -> Eio.Buf_read.take_all buf |> Kdl.of_string)
~max_size: max_int
flow
- |> Result.ok
+ with
+ | Ok doc -> Ok doc
+ | Error _ -> Error (`ParseError "KDL parse error")
with
| Kdl.Parse_error (msg, _) -> Error (`ParseError msg)