Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-11786

Callstack is not logged in js console log when exception happens in bridge call

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 6.1.1
    • None
    • cordova-js
    • all platform

    Description

      In cordova.js, callbackFromNative method, when handles the exception, it
      only logs the callbackid and error message, but does not log the error
      callstack. Usually the callstack is quite useful to find what causes the
      exception, so just wonder what is the reason to not include it in the error
      console log.

      If it is fine to include the call stack information in the console log, I
      would like to submit a pull request for the change.

         /**
            * Called by native code when returning the result from an action.
            */
           callbackFromNative: function(callbackId, isSuccess, status, args, keepCallback) {
               try {
                   var callback = cordova.callbacks[callbackId];
                   if (callback) {
                       if (isSuccess && status == cordova.callbackStatus.OK) {
                           callback.success && callback.success.apply(null, args);
                       } else if (!isSuccess) {
                           callback.fail && callback.fail.apply(null, args);
                       }
                       /*
                       else
                           Note, this case is intentionally not caught.
                           this can happen if isSuccess is true, but callbackStatus is NO_RESULT
                           which is used to remove a callback from the list without calling the callbacks
                           typically keepCallback is false in this case
                       */
                       // Clear callback if not expecting any more results
                       if (!keepCallback) {
                           delete cordova.callbacks[callbackId];
                       }
                   }
               }
               catch (err) {
                   var msg = "Error in " + (isSuccess ? "Success" : "Error") + " callbackId: " + callbackId + " : " + err;
                   console && console.log && console.log(msg);
                   cordova.fireWindowEvent("cordovacallbackerror", { 'message': msg });
                   throw err;
               }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            jonathanli Jonathan Li
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: