aboutsummaryrefslogtreecommitdiff
path: root/lib/kernel/overlay.ml
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-20 22:40:13 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-20 22:40:13 +0200
commitf73bd5d0e33146c24af1e98bf9ea26bd8cbf004b (patch)
tree790100dcc0077532d9446478e51d4cd40209c1c6 /lib/kernel/overlay.ml
parent2d8942e08edcbe5430f97270bdb1233e287600ee (diff)
parent671c4264707ec8c81845059746632b00f2481d88 (diff)
downloadcolitur-f73bd5d0e33146c24af1e98bf9ea26bd8cbf004b.tar.gz
colitur-f73bd5d0e33146c24af1e98bf9ea26bd8cbf004b.zip
Merge branch 'robustness-and-hackability'
An audit of the shipped program, plus the fixes it found. The citation parser accepted OCaml integer-literal syntax, so a typo like 'Luke 1_1:5' silently became a different chapter. Four pairs of different books shared a full title -- 1 and 2 Corinthians both rendered 'Epistola ad Corinthios' -- leaving 108 citations in 2027 alone that a reader could not resolve to a book. Spec section 8.5 is now delivered rather than recorded: shipped styles re-parse their own output. Overlay errors no longer name OCaml source files at the reader. Also: the new-overlay scaffold shows citations at the right nesting level, config --show validates before printing, error messages no longer echo whole file lines, and a month answers to both spellings of its own name.
Diffstat (limited to 'lib/kernel/overlay.ml')
-rw-r--r--lib/kernel/overlay.ml22
1 files changed, 3 insertions, 19 deletions
diff --git a/lib/kernel/overlay.ml b/lib/kernel/overlay.ml
index 58d8847..516379d 100644
--- a/lib/kernel/overlay.ml
+++ b/lib/kernel/overlay.ml
@@ -132,23 +132,6 @@ let fill_defaults ~id sexp =
actually reach a user into the vocabulary of the file they are looking at.
Anything unrecognised passes through verbatim rather than being reworded
into something possibly wrong. *)
-let humanise_error msg =
- let replace ~sub ~by s =
- let n = String.length sub and len = String.length s in
- let rec go i acc =
- if i > len - n then acc ^ String.sub s i (len - i)
- else if String.equal (String.sub s i n) sub then go (i + n) (acc ^ by)
- else go (i + 1) (acc ^ String.make 1 s.[i])
- in
- if n = 0 then s else go 0 ""
- in
- msg
- |> replace ~sub:"lib/kernel/celebration.ml.t_of_sexp" ~by:"celebration"
- |> replace ~sub:"lib/kernel/colour.ml.t_of_sexp" ~by:"colour"
- |> replace ~sub:"lib/kernel/subject.ml.t_of_sexp" ~by:"subject"
- |> replace ~sub:"lib/kernel/date_spec.ml.t_of_sexp" ~by:"date"
- |> replace ~sub:"lib/kernel/overlay.ml.directive_of_sexp" ~by:"directive"
-
let load rank_of_sexp path =
match Sexplib.Sexp.load_sexp path with
| exception Sys_error msg -> Error msg
@@ -157,7 +140,8 @@ let load rank_of_sexp path =
[Sexplib.Sexp.Parse_error], so a catch-all here -- placed last among the
exception branches -- is what actually keeps every parse failure inside
[Error] instead of escaping. *)
- | exception exn -> Error (Printf.sprintf "%s: %s" path (Printexc.to_string exn))
+ | exception exn ->
+ Error (Printf.sprintf "%s: %s" path (Sexp_error.humanise (Printexc.to_string exn)))
| sexp -> (
(* The overlay's own [id] is needed to default [layer], so read it off
the raw sexp first. If it is missing or malformed the derived parser
@@ -174,4 +158,4 @@ let load rank_of_sexp path =
match t_of_sexp rank_of_sexp (fill_defaults ~id sexp) with
| t -> Ok t
| exception exn ->
- Error (Printf.sprintf "%s: %s" path (humanise_error (Printexc.to_string exn))))
+ Error (Printf.sprintf "%s: %s" path (Sexp_error.humanise (Printexc.to_string exn))))