Sorry, that is not correct. If you read my post above, the response has not generated any error. The runtime error is not being generated by the response. The runtime error is being generated by a function called after a successful response.
In my code example above if I run the code without a network response the system generates a Run Time error. The app crashes and the error is displayed on the page. The Runtime:addEventListener( “unhandledError”, unhandledErrorListener ) can catch the error.
If the same code is run, but with a network request as part of that call, same error is generated, the words Runtime Error is output to the build window, but the app does not crash, the app does not display any error and the Runtime:addEventListener will not catch it.
You may say that all network.requests have to be end points e.g. they take no further action. However, practically this makes for a lot of unnecessary code, especially with a business app.
In my app before the scene loads I get some data from our cloud server. I don’t want the app to do anything else until the data has been retrieved, as dependent upon the data the screen may need to present data in a certain way. The logical way of managing this is by having a function or set of functions called following a successful network request. But, with this version of Corona, if any of those subsequent functions has some dodgy code or if the data is corrupted and causes a runtime error the app will not crash. The app just carries on, potentially in a very unstable state.
I have a work around, but I have a load of revisions to make to implement it.
My work around is to wrap any subsequent calls after a successful response with a timer.performWithDelay(). Here is an example of how the above code now works with the new wrapper - runtime error is now generated as it should be: -
Please - can you run the below code and just see the treatment. I would really appreciate it.
local test = {} local test = function() if tonumber(test[1].HasField) == 4 then print("test1") end end local function networkListener( event ) if ( event.isError ) then print( "Network error: ", event.response ) else -- toggle these two commands to see the different treatment of the error -- test() timer.performWithDelay(1, function() return test() end) end end -- Access Google network.request( "http://www.google.com", "GET", networkListener )