You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Introduce a setting for auto catching exceptions when calling JS method native #1119
We need a setting to enable and disable catching exceptions when calling the callJSMethodNative method. If enabled those exceptions will be caught an logged without propagating them.
The default value of that setting is false, so if such an error occurs it won't be caught and if not handled somewhere else will crash the application.
The flag is disabled by default, so if you want to enable it you should add in your app/package.json file this:
Where in package.json does this go? Top level, under nativescript: {}, somewhere else? Also, how do we know if the flag was picked up by the app or not?
@IAMtheIAM to test whether you have enabled the setting you can add throw new Error("MyError"); in a button click handler and check whether the app will crash or not when pressing the button. If the discardUncaughtJsExceptions is enabled you should only see the error in the log, if not the app would crash and show the error activity screen.
Thanks guys, that is exactly the info I was looking for. I recommend it be added to some docs somewhere, just as explained here to me. I read the Nativescript 4.2 update notice but was not sure which level it should be added to.
Activity
Add tests for issue NativeScript/android#1104 and NativeScript/androi…
Add tests for issue NativeScript/android#1104 and NativeScript/androi…
feat: Introduce a setting for discarding uncaught JS exceptions
IAMtheIAM commentedon Sep 3, 2018
Where in package.json does this go? Top level, under nativescript: {}, somewhere else? Also, how do we know if the flag was picked up by the app or not?
NickIliev commentedon Sep 4, 2018
@IAMtheIAM the setting should be placed in the application package.json located in the app folder
example
app/package.json{ "android": { "v8Flags": "--expose_gc" }, "main": "app.js", "name": "tns-template-hello-world-ts", "version": "4.1.0", "discardUncaughtJsExceptions":true }Documentation section here
vtrifonov commentedon Sep 4, 2018
@IAMtheIAM to test whether you have enabled the setting you can add
throw new Error("MyError");in a button click handler and check whether the app will crash or not when pressing the button. If the discardUncaughtJsExceptions is enabled you should only see the error in the log, if not the app would crash and show the error activity screen.IAMtheIAM commentedon Sep 4, 2018
Thanks guys, that is exactly the info I was looking for. I recommend it be added to some docs somewhere, just as explained here to me. I read the Nativescript 4.2 update notice but was not sure which level it should be added to.
soscler commentedon Nov 13, 2020
with nativescript angular the file is located in src/package.json