Skip to content

Commit 7039d8e

Browse files
committed
avoid regression in error message handling
1 parent 0c5b151 commit 7039d8e

File tree

7 files changed

+52
-45
lines changed

7 files changed

+52
-45
lines changed

jscomp/all.depend

+2-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ core/js_long.cmx : core/js_exp_make.cmx common/js_config.cmx core/j.cmx \
201201
core/js_main.cmx : core/ocaml_parse.cmx core/ocaml_options.cmx \
202202
core/ocaml_batch_compile.cmx core/js_implementation.cmx \
203203
common/js_config.cmx ext/ext_string.cmx ext/ext_filename.cmx \
204-
common/bs_pkg.cmx core/bs_conditional_initial.cmx core/js_main.cmi
204+
common/bs_pkg.cmx common/bs_exception.cmx core/bs_conditional_initial.cmx \
205+
core/js_main.cmi
205206
core/js_map.cmx : core/j.cmx
206207
core/js_number.cmx : core/js_number.cmi
207208
core/js_of_lam_array.cmx : core/js_exp_make.cmx core/js_of_lam_array.cmi

jscomp/bin/bsb.ml

+8-11
Original file line numberDiff line numberDiff line change
@@ -1624,7 +1624,14 @@ type error =
16241624
| Bs_package_not_found of string
16251625
| Bs_main_not_exist of string
16261626
| Bs_invalid_path of string
1627-
1627+
(*
1628+
TODO: In the futrue, we should refine dependency [bsb]
1629+
should not rely on such exception, it should have its own exception handling
1630+
*)
1631+
1632+
exception Error of error
1633+
1634+
val report_error : Format.formatter -> error -> unit
16281635
val error : error -> 'a
16291636

16301637
end = struct
@@ -1689,16 +1696,6 @@ let report_error ppf = function
16891696
| Bs_invalid_path path
16901697
-> Format.pp_print_string ppf ("Invalid path: " ^ path )
16911698

1692-
(**
1693-
FIXME: this introduces dependencies on compiler-libs
1694-
let () =
1695-
Location.register_error_of_exn
1696-
(function
1697-
| Error err
1698-
-> Some (Location.error_of_printer_file report_error err)
1699-
| _ -> None
1700-
)
1701-
*)
17021699

17031700

17041701
end

jscomp/bin/bsdep.ml

+8-11
Original file line numberDiff line numberDiff line change
@@ -4420,7 +4420,14 @@ type error =
44204420
| Bs_package_not_found of string
44214421
| Bs_main_not_exist of string
44224422
| Bs_invalid_path of string
4423-
4423+
(*
4424+
TODO: In the futrue, we should refine dependency [bsb]
4425+
should not rely on such exception, it should have its own exception handling
4426+
*)
4427+
4428+
exception Error of error
4429+
4430+
val report_error : Format.formatter -> error -> unit
44244431
val error : error -> 'a
44254432

44264433
end = struct
@@ -4485,16 +4492,6 @@ let report_error ppf = function
44854492
| Bs_invalid_path path
44864493
-> Format.pp_print_string ppf ("Invalid path: " ^ path )
44874494

4488-
(**
4489-
FIXME: this introduces dependencies on compiler-libs
4490-
let () =
4491-
Location.register_error_of_exn
4492-
(function
4493-
| Error err
4494-
-> Some (Location.error_of_printer_file report_error err)
4495-
| _ -> None
4496-
)
4497-
*)
44984495

44994496

45004497
end

jscomp/bin/whole_compiler.ml

+17-11
Original file line numberDiff line numberDiff line change
@@ -19861,7 +19861,14 @@ type error =
1986119861
| Bs_package_not_found of string
1986219862
| Bs_main_not_exist of string
1986319863
| Bs_invalid_path of string
19864-
19864+
(*
19865+
TODO: In the futrue, we should refine dependency [bsb]
19866+
should not rely on such exception, it should have its own exception handling
19867+
*)
19868+
19869+
exception Error of error
19870+
19871+
val report_error : Format.formatter -> error -> unit
1986519872
val error : error -> 'a
1986619873

1986719874
end = struct
@@ -19926,16 +19933,6 @@ let report_error ppf = function
1992619933
| Bs_invalid_path path
1992719934
-> Format.pp_print_string ppf ("Invalid path: " ^ path )
1992819935

19929-
(**
19930-
FIXME: this introduces dependencies on compiler-libs
19931-
let () =
19932-
Location.register_error_of_exn
19933-
(function
19934-
| Error err
19935-
-> Some (Location.error_of_printer_file report_error err)
19936-
| _ -> None
19937-
)
19938-
*)
1993919936

1994019937

1994119938
end
@@ -99381,6 +99378,15 @@ let set_eval_string s =
9938199378
eval_string := s
9938299379

9938399380

99381+
99382+
let () =
99383+
Location.register_error_of_exn
99384+
(function
99385+
| Bs_exception.Error err
99386+
-> Some (Location.error_of_printer_file Bs_exception.report_error err)
99387+
| _ -> None
99388+
)
99389+
9938499390
let (//) = Filename.concat
9938599391

9938699392
let add_package s =

jscomp/common/bs_exception.ml

-10
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,4 @@ let report_error ppf = function
5858
| Bs_invalid_path path
5959
-> Format.pp_print_string ppf ("Invalid path: " ^ path )
6060

61-
(**
62-
FIXME: this introduces dependencies on compiler-libs
63-
let () =
64-
Location.register_error_of_exn
65-
(function
66-
| Error err
67-
-> Some (Location.error_of_printer_file report_error err)
68-
| _ -> None
69-
)
70-
*)
7161

jscomp/common/bs_exception.mli

+8-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,12 @@ type error =
2929
| Bs_package_not_found of string
3030
| Bs_main_not_exist of string
3131
| Bs_invalid_path of string
32-
32+
(*
33+
TODO: In the futrue, we should refine dependency [bsb]
34+
should not rely on such exception, it should have its own exception handling
35+
*)
36+
37+
exception Error of error
38+
39+
val report_error : Format.formatter -> error -> unit
3340
val error : error -> 'a

jscomp/core/js_main.ml

+9
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ let set_eval_string s =
6161
eval_string := s
6262

6363

64+
65+
let () =
66+
Location.register_error_of_exn
67+
(function
68+
| Bs_exception.Error err
69+
-> Some (Location.error_of_printer_file Bs_exception.report_error err)
70+
| _ -> None
71+
)
72+
6473
let (//) = Filename.concat
6574

6675
let add_package s =

0 commit comments

Comments
 (0)