RealHandy opened a new issue #809: Logger fails to print 'message' field of 
Error exception
URL: https://github.com/apache/cordova-ios/issues/809
 
 
   # Bug Report
   
   cordova.js on iOS seems unable to properly log a thrown exception of type 
Error
   
   ## Problem
   
   Found this in IndoorAtlas, but it could happen anywhere. IndoorAtlas 
correctly detects an error in a passed argument and throws an exception like 
this:
   
https://github.com/IndoorAtlas/cordova-plugin/blob/5df032179d5237b26f25594e19f83f0541178a9d/www/IndoorAtlas.js#L516
   ```
      if (!isNumber(position.latitude) || !isNumber(position.longitude))
         throw new Error('setPosition: invalid or missing coordinates');
   ```
   which throws an Error object like this:
   ```
   {
     column: 87,
     line: 517,
     message: "setPosition: invalid or missing coordinates",
     sourceURL: 
"http://localhost:12101/plugins/cordova-plugin-indooratlas/www/IndoorAtlas.js";,
     stack: 
"http://localhost:12101/plugins/cordova-plugin-indooratlas/www/IndoorAtlas.js:517:8…";
   }
   ```
   
   ### What is expected to happen?
   
   It should log the error in a manner that includes the meaningful message 
originally thrown as the error, i.e., "setPosition: invalid or missing 
coordinates"
   
   
   ### What does actually happen?
   
   The output to the log is actually this -- no mention of the 'message' field 
in the thrown object:
   ```
   2020-03-17 16:06:29.575296-0400 Vium[45367:3592590] ERROR:
   
{"line":517,"column":87,"sourceURL":"http://localhost:12101/plugins/cordova-plugin-indooratlas/www/IndoorAtlas.js"}
   ```
   
   ## Information
   <!-- Include all relevant information that might help understand and 
reproduce the problem -->
   cordova.js, in processing the exception to log it, calls this:
   
https://github.com/apache/cordova-ios/blob/d8f4b62d4da8eca8226de8bb79fbc91a949f9850/CordovaLib/cordova.js#L1624
   
   Which calls this:
   
https://github.com/apache/cordova-ios/blob/d8f4b62d4da8eca8226de8bb79fbc91a949f9850/CordovaLib/cordova.js#L1670
   
   Which calls this:
   
https://github.com/apache/cordova-ios/blob/d8f4b62d4da8eca8226de8bb79fbc91a949f9850/CordovaLib/cordova.js#L1712
   
   Which, because the logging code has determined that "%o" is the format to 
apply to logging this object, calls this:
   
https://github.com/apache/cordova-ios/blob/d8f4b62d4da8eca8226de8bb79fbc91a949f9850/CordovaLib/cordova.js#L1726
   
   Something about the calling or behavior of the JSON.stringify() call returns 
"" instead of something correct, and the message gets lost.
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   It appears all you have to do is throw a new Error and have it make it 
uncaught through to cordova's logger.
   
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you 
experiencing the issue? -->
   iOS. The lines above are taken from `cordova.js`.
   
   
   ### Version information
   <!-- 
   What are relevant versions you are using?
   It's Meteor 1.9.2, but I've pulled these lines from the current version of 
`cordova.js`
   -->
   
   
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x] I searched for existing GitHub issues
   - [x] I updated all Cordova tooling to most recent version for Meteor
   - [x] I included all the necessary information above
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to