Skip to content

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

@vtrifonov

Description

@vtrifonov

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;
    }
}

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions