Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a setting to wrap calls to CallJSMethod in try catch #1223

Closed
vtrifonov opened this issue Dec 5, 2018 · 0 comments
Closed

Add a setting to wrap calls to CallJSMethod in try catch #1223

vtrifonov opened this issue Dec 5, 2018 · 0 comments
Assignees
Milestone

Comments

@vtrifonov
Copy link
Contributor

Add a setting to wrap the calls in to CallJSMethod generated from the SBG in try-catch block to avoid throwing exceptions from their execution.

The setting can be enabled in the app/package.json file:

{
    "main": "main.js",
    "android": {
        "suppressCallJSMethodExceptions": true
    }
}

If enabled instead of generating code like this:

public boolean onQueryTextChange(java.lang.String param_0)  {
    java.lang.Object[] args = new java.lang.Object[1];
    args[0] = param_0;
    return (boolean)com.tns.Runtime.callJSMethod(this, "onQueryTextChange", boolean.class, args);
}

SBG will generate code like this:

public boolean onQueryTextChange(java.lang.String param_0)  {
    java.lang.Object[] args = new java.lang.Object[1];
    args[0] = param_0;
    try {
        return (boolean)com.tns.Runtime.callJSMethod(this, "onQueryTextChange", boolean.class, args);
    } catch (Throwable t) {
        android.util.Log.w("Error", t);
        return false;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants