Requesting: "Debug Mode" for running on iPhone

One of the more annoying features of the system as it stands right now is if there’s an error (a run-time error) when my App is running on my iPhone, it continues to run. Specifically, it tries to ignore the error and continue on.

This is bad on many levels (think data corruption for preferences files, etc), but it makes it nigh impossible to catch some bugs.

My request is to have an event for handling run-time errors. This allows me to pop up a dialog with some info in it and then exit gracefully (or just plain exit gracefully… or attempt to continue if that’s my choice). While not bulletproof, this would be a huge step towards being *better* than Apps that simply just crash (heck you could even have a stack trace emailed to you or dumped into a URL) on the phone (the standard for non-corona apps) or attempt to keep running, sometimes causing more damage and making devs think the bug is in other areas.

Thanks,
Scott

P.S. If this is already possible, please slap me around and point me to some documentation! :slight_smile: [import]uid: 5659 topic_id: 786 reply_id: 300786[/import]

From the Lua manual: If you need to catch errors in Lua, you can use the pcall function.

http://www.lua.org/manual/5.1/manual.html

Can you give this a whirl? [import]uid: 54 topic_id: 786 reply_id: 1631[/import]

Hmm. If I read this correctly, one would need to wrap every function call with pcall(…).

I’m looking for something far more generic, just a way to “exit on error” when running on the iPhone/iPad/Android/OtherHardware rather than continuing to run even though there’s been a run-time error.

Adding another event to the Runtime object… maybe something like this:

[code]Runtime:addEventListener( “runTimeError”, onRunTimeError )

function onRunTimeError() native.showAlert("Crash", "There has been a catastrophic error. Please contact blahblahblah", { "Exit" }); os.exit(1); end

If more can be passed to this function call, like a stack trace message, etc., great. It may be that it’s not possible to call back into App once it’s hit a run-time error (which would seem odd since it doesn’t appear to have a problem ignoring the error and continuing on). If that were the case, then being able to initialize with a new lua file (Error.lua) in which resides an error function that is called… that would work as well.

Heck, having some flags we could set like:

os.showError = true; os.runTimeErrorExits = true;

would work as well. Having more flexibility with a function that gets called would be ideal as we could decide what to do, but anything is better than continuing to execute (IMO).

Of course, I’d also want a way to know I’m running on the simulator so I can *not* do these things since I want to see my stack trace instead.

Scott [import]uid: 5659 topic_id: 786 reply_id: 1637[/import]