@@ -6,11 +6,28 @@ Make sure to use "-g" flags when compiling and linking ocaml bytecode.
66Js_of_ocaml will attempt to preserve variable names.
77
88=== Js_of_ocaml flags
9- * [--pretty] - format the generated JavaScript in a readable way and try to keep OCaml variable names.
9+ * [--pretty] - format the generated JavaScript in a readable way and try to keep OCaml variable names.
1010 * [--no-inline] - prevent function inlining.
1111 * [--debug-info] - annotate the JavaScript file with locations from the OCaml sources.
1212 * [--source-map] - enable source-map support
1313
14+ == JavaScript stacktrace
15+ Js_of_ocaml can attach a JavaScript [Error] that embed the current
16+ stacktrace to an OCaml exception. The [Error] can be attached with
17+ {{{Js.Js_error.attach_js_backtrace }}} and extracted using
18+ {{{Js.Js_error.of_exn }}}. Un-handled OCaml exception will throw any
19+ JavaScript [Error] attached to them, allowing the JS engine to display
20+ the stacktrace nicely.
21+
22+ Js_of_ocaml will attach an [Error] automatically when raising an OCaml
23+ exception (with {{{raise }}}, not with {{{raise_notrace }}}) if
24+ {{{Printexc.backtrace_status() = true }}} and either the environment
25+ variable [OCAMLRUNPARAM] is set with [b=1 ] or the program was compiled
26+ with [--enable with-js-error ].
27+
28+ Note that creating JavaScript [Error]s is costly and can degrade performance a lot.
29+ This is the reason why such feature is not enabled by default.
30+
1431== Breakpoint
1532One can set breakpoints using developers tools (see https://developer.chrome.com/devtools/docs/javascript-debugging).
1633Alternatively, one can set breakpoints programmatically by calling {{{Js.debugger () }}}. Note that
0 commit comments