js_of_ocaml icon indicating copy to clipboard operation
js_of_ocaml copied to clipboard

[FEATURE REQUEST] Server-side uses of unimplemented primitives are difficult to track down

Open adrien-n opened this issue 7 years ago • 1 comments

I'm opening this a bit late and I may have forgotten part of the context. Please forgive me if this is the case.

Currently an unimplemented javascript primitive triggers an exit(1) (server-side iirc). This makes it difficult to find which code path is faulty. Mixing server-side and client-side should not happen but mistakes do.

I've used the following change to generate_stubs.sh locally:

-echo "#define D(f) void f () { fprintf(stderr, "Unimplemented Javascript primitive %s!\n", #f); exit(1); }"; +echo "#define D(f) void f () { fprintf(stderr, "Unimplemented Javascript primitive %s!\n", #f); caml_failwith("Unimplemented Javascript primitive: " # f); exit(1); }";

I wasn't able to get a full backtrace but at least I was able to ocamldebug it.

Maybe a dedicated exception could be useful, especially because Invalid_argument might be caught and silenced.

adrien-n avatar May 31 '18 12:05 adrien-n

It seems too easy to silently drop an exceptions. I would rather print the backtrace and exit.

hhugo avatar Jul 09 '18 18:07 hhugo