Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-24657

Hyperloop: Android - Support to catch native exceptions

    Details

    • Story Points:
      5
    • Sprint:
      2017 Sprint 23 SDK

      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:

      [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)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jvennemann Jan Vennemann
                Reporter:
                jormagar Jorge Macias Garcia
                Reviewer:
                Christopher Williams
              • Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Git Source Code