ocaml
0
fork

Configure Feed

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

Legacy_xml_client: best effort scoping of errors

We don't know the exact range but at least we can find the file name.

References: https://todo.sr.ht/~jonsterling/forester/165

+18 -4
+18 -4
lib/frontend/Legacy_xml_client.ml
··· 48 48 URI.make ~path () 49 49 | _ -> uri 50 50 51 - module Scope = Algaeff.Reader.Make(struct type t = URI.t option end) 51 + module Scope = struct 52 + open struct module E = Algaeff.Reader.Make(struct type t = URI.t option end) end 53 + let read = E.read 54 + 55 + let run ~(forest : State.t) ~env kont = 56 + let@ () = E.run ~env in 57 + let loc_opt = 58 + let@ uri = Option.bind env in 59 + let@ path = Option.map @~ State.source_path_of_uri uri forest in 60 + let position = Range.{source = `File path; offset = 0; start_of_line = 0; line_num = 0} in 61 + Range.make (position,position) 62 + in 63 + let@ () = Reporter.with_loc loc_opt in 64 + kont () 65 + end 66 + 52 67 module Loop_detection = Loop_detection_effect.Make () 53 68 54 69 (* It's fine to have a global transclusion cache since URIs fully qualify a tree*) ··· 82 97 (render_section_flags section.flags) 83 98 [ 84 99 render_frontmatter forest section.frontmatter; 85 - let@ () = Scope.run ~env: section.frontmatter.uri in 100 + let@ () = Scope.run ~forest ~env: section.frontmatter.uri in 86 101 X.mainmatter [] @@ 87 102 if Loop_detection.have_seen_uri_opt section.frontmatter.uri then 88 103 [X.info [] [P.txt "Transclusion loop detected, rendering stopped."]] ··· 313 328 Logs.debug (fun m -> m "[Performance] rendering %a took %f seconds" Format.(pp_print_option URI.pp) article.frontmatter.uri elapsed); 314 329 result 315 330 in 316 - let@ () = Reporter.tracef "when rendering article %a" Format.(pp_print_option URI.pp) article.frontmatter.uri in 317 331 let config = forest.config in 318 332 let@ () = Loop_detection.run in 319 - let@ () = Scope.run ~env: article.frontmatter.uri in 333 + let@ () = Scope.run ~forest ~env: article.frontmatter.uri in 320 334 let@ xmlnss = Xmlns.run in 321 335 let@ () = In_backmatter.run ~env: false in 322 336 X.tree