Skip to content

Commit f0b1228

Browse files
committed
use Js.Exn.raiseError and include ReScript file name + location of todo code in error thrown at runtime
1 parent a383dc6 commit f0b1228

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

jscomp/frontend/ast_exp_extension.ml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,26 @@ let handle_extension e (self : Bs_ast_mapper.mapper)
3333
| None -> None
3434
in
3535
Location.prerr_warning e.Parsetree.pexp_loc (Bs_todo todo_message);
36+
let pretext =
37+
loc.loc_start.pos_fname ^ ":"
38+
^ string_of_int loc.loc_start.pos_lnum
39+
^ ":"
40+
^ string_of_int loc.loc_start.pos_cnum
41+
^ "-"
42+
^ string_of_int loc.loc_end.pos_cnum
43+
in
44+
3645
Exp.apply ~loc
37-
(Exp.ident ~loc {txt = Longident.parse "failwith"; loc})
46+
(Exp.ident ~loc {txt = Longident.parse "Js.Exn.raiseError"; loc})
3847
[
3948
( Nolabel,
4049
Exp.constant ~loc
4150
(Pconst_string
42-
( (match todo_message with
43-
| None -> "todo"
44-
| Some msg -> msg),
51+
( (pretext
52+
^
53+
match todo_message with
54+
| None -> " - Todo"
55+
| Some msg -> " - Todo: " ^ msg),
4556
None )) );
4657
]
4758
| "ffi" -> Ast_exp_handle_external.handle_ffi ~loc ~payload

0 commit comments

Comments
 (0)