12
12
(* special exception on linking described in the file LICENSE. *)
13
13
(* *)
14
14
(* *************************************************************************)
15
- [@@@ bs.config { flags = [|" -bs-no-cross-module-opt" |]}]
16
-
15
+ [@@@ bs.config { flags = [| " -bs-no-cross-module-opt" |] }]
17
16
18
17
let printers = ref []
19
18
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
23
26
24
- let fields : exn -> string = [% raw{| function(x){
27
+ let fields : exn -> string =
28
+ [% raw
29
+ {| function(x){
25
30
var s = " "
26
31
var index = 1
27
32
while (" _" + index in x){
@@ -33,47 +38,38 @@ let fields : exn -> string = [%raw{|function(x){
33
38
}
34
39
return " (" + s + " )"
35
40
}
36
- | }]
37
-
38
-
39
-
40
-
41
+ | }]
41
42
42
43
external exn_slot_name : exn -> string = " ?exn_slot_name"
43
44
44
- let to_string x =
45
+ let to_string x =
45
46
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
+ | [] -> (
51
50
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"
58
57
| _ ->
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
62
61
conv ! printers
63
62
64
63
let print fct arg =
65
- try
66
- fct arg
64
+ try fct arg
67
65
with x ->
68
66
Js. log (" Uncaught exception: " ^ to_string x);
69
67
raise x
70
68
71
69
let catch fct arg =
72
- try
73
- fct arg
70
+ try fct arg
74
71
with x ->
75
72
Js. log (" Uncaught exception: " ^ to_string x);
76
73
exit 2
77
74
78
- let register_printer fn =
79
- printers := fn :: ! printers
75
+ let register_printer fn = printers := fn :: ! printers
0 commit comments