Emscripten - how to see JS console exceptions?

I have compiled my project using:

emmake make

Compiles OK - I then run it using either of these:

emrun --browser chrome bin/myproject.html
emrun --browser firefox bin/myproject.html

In the javascript console I get this message:

Uncaught 38782240 - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.

But I don’t know what to do with it. It seems this flag is for when you are compiling using emcc, not make.

Do I have to do something like this with it? (this fails on the first include in the file)

emcc -s DISABLE_EXCEPTION_CATCHING=0 src/ofApp.cpp

you can add flags that should be passed to the compiler in the config.make file of your project, look for PROJECT_CFLAGS, uncomment it and add add something like:

PROJECT_CFLAGS=-s DISABLE_EXCEPTION_CATCHING=0

Thanks. I followed your instructions then saved config.make, ran emmake make and emrun as before.

It still gives me the same console error:

Uncaught 38782240 - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.

I tried it both ways:

PROJECT_CFLAGS=-s DISABLE_EXCEPTION_CATCHING=0
PROJECT_CFLAGS=-s DISABLE_EXCEPTION_CATCHING=2

Emscripten people helped me out here. It seems that the flag needs to be set at the final step of compilation, when the .html file is generated. The PROJECT_CFLAGS are only using the flag when .cpp files are compiled.

I couldn’t figure out how to automate this using config.make, but I was able to get it working by repeating the .html compilation step after emmake make finishes, and adding on the flag I want.

It looks like this:

/Users/admin/bin/emsdk_portable/emscripten/1.35.0/em++ -o bin/myproject.html -O3 -s OUTLINING_LIMIT=100000 -s TOTAL_MEMORY=134217728  -s DISABLE_EXCEPTION_CATCHING=0  --memory-init-file 1  obj/emscripten/Release/src/animation.o obj/emscripten/Release/src/main.o obj/emscripten/Release/src/ofApp.o ../../../addons/obj/emscripten/Release/ofxEmscripten/src/ofxAppEmscriptenWindow.o ../../../addons/obj/emscripten/Release/ofxEmscripten/src/ofxEmscriptenSoundPlayer.o ../../../addons/obj/emscripten/Release/ofxEmscripten/src/ofxEmscriptenSoundStream.o ../../../addons/obj/emscripten/Release/ofxEmscripten/src/ofxEmscriptenURLFileLoader.o ../../../addons/obj/emscripten/Release/ofxEmscripten/src/ofxEmscriptenVideoGrabber.o ../../../addons/obj/emscripten/Release/ofxEmscripten/src/ofxEmscriptenVideoPlayer.o ../../../addons/obj/emscripten/Release/ofxJSON/src/ofxJSONElement.o ../../../addons/obj/emscripten/Release/ofxJSON/libs/jsoncpp/src/jsoncpp.o ../../../addons/obj/emscripten/Release/ofxLayerMask/src/ofxLayerMask.o ../../../addons/obj/emscripten/Release/ofxTexturePlane/src/ofxTexturePlane.o ../../../addons/obj/emscripten/Release/ofxAnimatable/src/ofxAnimatable.o ../../../addons/obj/emscripten/Release/ofxAnimatable/src/ofxAnimatableFloat.o ../../../addons/obj/emscripten/Release/ofxAnimatable/src/ofxAnimatableOfColor.o ../../../addons/obj/emscripten/Release/ofxAnimatable/src/ofxAnimatableOfPoint.o ../../../libs/openFrameworksCompiled/lib/emscripten/libopenFrameworks.bc   -Wl,--as-needed -Wl,--gc-sections --preload-file bin/data@data --emrun --js-library ../../../addons/ofxEmscripten/libs/html5video/lib/emscripten/library_html5video.js --js-library ../../../addons/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js --shell-file ../../../libs/openFrameworksCompiled/project/emscripten/template.html ../../../libs/FreeImage/lib/emscripten/libfreeimage.a ../../../libs/boost/lib/emscripten/libboost_filesystem.a ../../../libs/boost/lib/emscripten/libboost_system.a ../../../libs/tess2/lib/emscripten/libtess2.a    ../../../libs/freetype/lib/emscripten/libfreetype.bc

Thanks

you should be able to add them in PROJECT_LDFLAGS

Awesome. Yes, that works too