try catch doesn't always work

rocfusion 5 years ago in iRidium Script / AV and Driver scripts updated by Oksana (expert) 5 years ago 4

I have a script that parses an object.  Not every record contains the same fields. 

Only through breaking some other code in another script did the try catch statement trigger and the error was shown.

This is an simplified example of what I was trying. 

myobject =  [{ test : [data:"123",data:"1234"], test2:"abcd"}, { test : [data:"13",data:"134"], test2:"abc"},
      {  test2:"abcd"}];

try {
    IR.Log("y is "+y)
}catch(error){IR.Log("there was an error  "+error)

I think that when you try this as a stand alone script its fine, yet when this example is used in an more complex project that contains multiple drivers then the try catch become less reliable.  My project contains  KNX, SIP, SONOS, XBMC,  Global cache, denon; plus more.


Hi Roger!

The error in the Log is a string from IR.Log method

IR.Log("there was an error  " + error)

if change this line then  error not will show:
IR.Log("there was an error  ")

Will this still tell  me where the code is broken?


Hi Roger, yes.

The script error showed message is information message, not message of breaking the code in Console Log.

there was an error  ReferenceError: C:\Users\Sergey\Documents\iRidium mobile 2\Settings\iRidium\Main\te.js:5: test - It is message from error variable