Skip to content

Commit bbaf228

Browse files
committed
Deploying to wikidoc from @ b64a46c 🚀
1 parent b749c91 commit bbaf228

File tree

15 files changed

+65
-37
lines changed

15 files changed

+65
-37
lines changed

doc/dev/manual/debug.wiki

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,28 @@ Make sure to use "-g" flags when compiling and linking ocaml bytecode.
66
Js_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
1532
One can set breakpoints using developers tools (see https://developer.chrome.com/devtools/docs/javascript-debugging).
1633
Alternatively, one can set breakpoints programmatically by calling {{{Js.debugger ()}}}. Note that
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
= Environment variables
2+
3+
To resolve an environment variable, js_of_ocaml will perform the
4+
following steps, in the given order:
5+
6+
- If the variable was set at compile time with the [--setenv VAR] flag, return it.
7+
- If running nodejs and the variable is set in the process environment ([process.env]), return it.
8+
- If the variable is set in [globalThis.jsoo_env], return it. This can be used
9+
to set an environment variable inside a web-browser.
10+
- Return Not_found

doc/dev/manual/files/boulderdash/boulderdash.bc.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/dev/manual/files/cubes/cubes.bc.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/dev/manual/files/graph_viewer/viewer_js.bc.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/dev/manual/files/hyperbolic/hypertree.bc.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)