Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24657] Hyperloop: Android - Support to catch native exceptions

GitHub Issuen/a
TypeNew Feature
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-11-17T20:43:31.000+0000
Affected Version/sn/a
Fix Version/sHyperloop 3.0.0
ComponentsHyperloop
LabelsEscalation, android, exceptions, hyperloop
ReporterJorge Macias Garcia
AssigneeJan Vennemann
Created2017-05-04T07:07:41.000+0000
Updated2017-11-28T09:43:42.000+0000

Description

It would be interesting to catch exceptions thrown in the hyperloop proxy. Example:
var Activity = require('android.app.Activity'),
    activity = new Activity(Ti.Android.currentActivity);

  var PackageManager = require('android.content.pm.PackageManager');

  var pm = activity.getPackageManager();
  var isInstalled = true;
  var package = 'com.thisPackageNotExists';

  try {
    var packageInfo = pm.getPackageInfo(package, PackageManager.GET_ACTIVITIES); //Throws NameNotFoundException
  } catch (error) {
    //This block never is executed if the exception is thrown
    isInstalled = false;
    console.log('Exception PM : ' + JSON.stringify(error));
  } finally {
    alert(package + ' is installed: ' + isInstalled);
  }
Exception Example: {noformat} [ERROR] HyperloopProxy: (main) [285,285] Exception thrown during invocation of method: public android.content.pm.PackageInfo android.app.ApplicationPackageManager.getPackageInfo(java.lang.String,int) throws android.content.pm.PackageManager$NameNotFoundException, args: [com.jormagar.packageManagerrs, 1] [ERROR] HyperloopProxy: android.content.pm.PackageManager$NameNotFoundException: com.jormagar.packageManagerrs [ERROR] HyperloopProxy: at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:137) [ERROR] HyperloopProxy: at java.lang.reflect.Method.invoke(Native Method) [ERROR] HyperloopProxy: at hyperloop.BaseProxy.invokeMethod(BaseProxy.java:145) [ERROR] HyperloopProxy: at hyperloop.InstanceProxy.invokeMethod(InstanceProxy.java:183) [ERROR] HyperloopProxy: at hyperloop.BaseProxy.callNativeFunction(BaseProxy.java:127) [ERROR] HyperloopProxy: at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method) [ERROR] HyperloopProxy: at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62) [ERROR] HyperloopProxy: at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:872) [ERROR] HyperloopProxy: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1095) [ERROR] HyperloopProxy: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:357) [ERROR] HyperloopProxy: at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:116) [ERROR] HyperloopProxy: at ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:453) [ERROR] HyperloopProxy: at android.os.Handler.dispatchMessage(Handler.java:98) [ERROR] HyperloopProxy: at android.os.Looper.loop(Looper.java:148) [ERROR] HyperloopProxy: at android.app.ActivityThread.main(ActivityThread.java:5417) [ERROR] HyperloopProxy: at java.lang.reflect.Method.invoke(Native Method) [ERROR] HyperloopProxy: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) [ERROR] HyperloopProxy: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) {noformat}

Comments

  1. Jan Vennemann 2017-11-15

    PR: https://github.com/appcelerator/hyperloop.next/pull/258

JSON Source