Source locations and structured errors for text codecs (extracted from jsont)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

encodings: document and apply Error builder/raiser pair convention

Per the updated ocaml-encodings skill, every typed error helper ships
as a pair: [foo meta ~args] builds a [t], [fail_foo meta ~args]
raises it. Callers can either accumulate errors (build only) or
abort immediately (raise) without the vocabulary fragmenting.

- SKILL.md: document the convention in the Error section.
- loc/README.md: clarify that [exception Loc.Error] is the single
shared raise site and re-exports use the pair naming.
- loc/test/test_loc.ml: rename test cases to the [fail_*] verbs
(Error.fail_expected, Error.fail_push_array).
- xml/xml.mli: update the Error facade doc to point at
[Error.fail_sort] / [Error.fail_kinded_sort] (the raising verbs)
rather than [sort] / [kinded_sort] (the builders).
- oci/spec/error.ml: use [Json.Error.failf] instead of [fail] + an
intermediate format, keeping the structured path/meta.
- json/sort.mli: tiny docstring cleanup ({!Loc.Path} -> "path").

+4 -3
+1 -1
README.md
··· 16 16 - `Loc.Meta` — node metadata: source location and surrounding whitespace 17 17 - `Loc.Path` — structural paths (`Mem of string node | Nth of int node`) 18 18 - `Loc.Context` — navigation contexts accumulated during descent 19 - - `Loc.Error` — structured errors with an {i extensible} kind, source 19 + - `Loc.Error` — structured errors with an *extensible* kind, source 20 20 location, and contextual path; formatted per the OCaml compiler / 21 21 GNU error conventions 22 22 - `exception Loc.Error of Loc.Error.t` — single shared exception for
+3 -2
test/test_loc.ml
··· 305 305 Alcotest.test_case "Path.of_string error" `Quick path_of_string_err; 306 306 Alcotest.test_case "Error.msg / to_string" `Quick error_msg; 307 307 Alcotest.test_case "Error.msg raises" `Quick error_msg_raises; 308 - Alcotest.test_case "Error.expected raises" `Quick error_expected_raises; 309 - Alcotest.test_case "Error.push_array" `Quick error_push_context; 308 + Alcotest.test_case "Error.fail_expected raises" `Quick 309 + error_expected_raises; 310 + Alcotest.test_case "Error.fail_push_array" `Quick error_push_context; 310 311 Alcotest.test_case "Error.pp mentions path" `Quick error_pp_mentions_path; 311 312 Alcotest.test_case "Error.kind extension + printer" `Quick 312 313 error_kind_extension;