1212(* special exception on linking described in the file LICENSE. *)
1313(* *)
1414(* *************************************************************************)
15- [@@@ bs.config { flags = [|" -bs-no-cross-module-opt" |]}]
16-
15+ [@@@ bs.config { flags = [| " -bs-no-cross-module-opt" |] }]
1716
1817let printers = ref []
1918
20- let locfmt s (linum : int ) (start : int ) (finish : int ) msg =
21- {j| File " $(s)" , line $ (linum), characters $ (start)-$ (finish): $ (msg)| j}
22-
19+ let locfmt s (linum : int ) (start : int ) (finish : int ) msg =
20+ ((((((((" File \" " ^ s) ^ " \" , line " ) ^ __unsafe_cast linum) ^ " , characters " )
21+ ^ __unsafe_cast start)
22+ ^ " -" )
23+ ^ __unsafe_cast finish)
24+ ^ " : " )
25+ ^ msg
2326
24- let fields : exn -> string = [% raw{| function(x){
27+ let fields : exn -> string =
28+ [% raw
29+ {| function(x){
2530 var s = " "
2631 var index = 1
2732 while (" _" + index in x){
@@ -33,47 +38,38 @@ let fields : exn -> string = [%raw{|function(x){
3338 }
3439 return " (" + s + " )"
3540}
36- | }]
37-
38-
39-
40-
41+ | }]
4142
4243external exn_slot_name : exn -> string = " ?exn_slot_name"
4344
44- let to_string x =
45+ let to_string x =
4546 let rec conv = function
46- | hd :: tl ->
47- (match try hd x with _ -> None with
48- | Some s -> s
49- | None -> conv tl)
50- | [] ->
47+ | hd :: tl -> (
48+ match try hd x with _ -> None with Some s -> s | None -> conv tl)
49+ | [] -> (
5150 match x with
52- | Match_failure (file , line , char ) ->
53- locfmt file line char (char + 5 ) " Pattern matching failed"
54- | Assert_failure (file , line , char ) ->
55- locfmt file line char (char + 6 ) " Assertion failed"
56- | Undefined_recursive_module (file , line , char ) ->
57- locfmt file line char (char + 6 ) " Undefined recursive module"
51+ | Match_failure (file , line , char ) ->
52+ locfmt file line char (char + 5 ) " Pattern matching failed"
53+ | Assert_failure (file , line , char ) ->
54+ locfmt file line char (char + 6 ) " Assertion failed"
55+ | Undefined_recursive_module (file , line , char ) ->
56+ locfmt file line char (char + 6 ) " Undefined recursive module"
5857 | _ ->
59- let constructor =
60- exn_slot_name x in
61- constructor ^ fields x in
58+ let constructor = exn_slot_name x in
59+ constructor ^ fields x)
60+ in
6261 conv ! printers
6362
6463let print fct arg =
65- try
66- fct arg
64+ try fct arg
6765 with x ->
6866 Js. log (" Uncaught exception: " ^ to_string x);
6967 raise x
7068
7169let catch fct arg =
72- try
73- fct arg
70+ try fct arg
7471 with x ->
7572 Js. log (" Uncaught exception: " ^ to_string x);
7673 exit 2
7774
78- let register_printer fn =
79- printers := fn :: ! printers
75+ let register_printer fn = printers := fn :: ! printers
0 commit comments