Skip to content

Commit

Permalink
ppx: better error message for include_script
Browse files Browse the repository at this point in the history
  • Loading branch information
pveber committed Jan 31, 2021
1 parent 853d540 commit 03f1d9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions ppx/bistro_script.ml
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,16 @@ let includee_loc ~file_name ~file_contents =
let loc_end = loc_end ~file_name ~file_contents in
{ Location.loc_start ; loc_end ; loc_ghost = false }

let include_rewriter ~loc:_ ~path:_ { txt = fn ; loc = _ } =
let include_rewriter ~loc:_ ~path:_ { txt = fn ; loc } =
match Stdio.In_channel.read_all fn with
| contents ->
let loc = includee_loc ~file_name:fn ~file_contents:contents in
rewrite contents loc
| exception _ ->
let module Location = Ocaml_common.Location in
let msg =
Printf.sprintf
"Cannot read %s, for dune users please use preprocessor_deps"
"Cannot read %s, have you forgot to add it in a preprocessor_deps field of your dune file?"
fn in
failwith msg
let err = Location.error ~loc msg in
raise (Location.Error err)
2 changes: 1 addition & 1 deletion test/template.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{{string title}}
<<<string title>>>
================================

0 comments on commit 03f1d9f

Please sign in to comment.