3 Replies Latest reply on Feb 21, 2016 3:00 PM by Hal P Anderson

    loadstring & LrSocket.bind

    kimaldis Level 1

      I have a function that creates an LrSocket for receiving data. All works fine. Within the onMessage callback I'm using loadstring() to run some Luacode, as below. This also works fine until there's a syntax error in thecodestring passed to loadstring(). Normally, ouside of onMessage, there'd be some kind of  error message but within onMessage, it just dies quietly. I'd like to have some indication of where the error is. I've tried using pcall() and I've tried wrapping it in an assert(). Neither works. I wondered if anybody maybe had any thoughts.




                  onMessage = function( socket, message )
                      local code = "LrDialogss.showBezel( 'Test Message', 5 )"  -- deliberate syntax error
                      local f = assert( loadstring( code )  )
                      Debug.logn( "Done Loadstring" )
                      Debug.logn( "Done Function Call" ) -- never gets here if error in 'code'