Hello everyone! I just wanted to see if anyone knew of a way to log errors, or log events in a log file on mobile devices.
I would like to have the system let me know what it is up to on the mobile device. I have found multiple terms for doing it on desktop like using the word "scriptExecutionError," but I searched through the library and there was nothing that was compatible for mobile.
My goal with this is to see what my app is doing right before a) something doesn't function properly or b) it force quits. It would need to build this log in real time and have it saved to a file outside of the app (I think) so that the information is preserved, and may be sent to the cloud for inspection upon restarting the application.
Is there an extension for this? Or does anyone know the best way to do that?
This is an open discussion. Please post any and all thoughts and comments!
Thanks for your interest!
Error log for Mobile
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 212
- Joined: Fri Feb 01, 2013 1:31 am
- Contact:
Re: Error log for Mobile
Hi,
On iOS, the put command displays text in the console, while in the IDE the text is displayed in the message box.
Kind regards,
Mark
On iOS, the put command displays text in the console, while in the IDE the text is displayed in the message box.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Error log for Mobile
From Livecode User Guide:
10.4 Custom Error handling
If you are creating an application that is going to be distributed, you may want to include a method for catching and handling errors. LiveCode provides two such methods. The first is the try/catch control structure. This control structure can be inserted around any routine that you know may encounter problems when in use. For example, you may wish to include this around a routine that reads in a file from disk to handle the case where a corrupted file has been selected. The second method is to write a custom errorDialog routine. Unlike a try/catch control structure, an errorDialog handler is global to your application (or card or stack within an application) and does not provide a mechanism to allow a script that encounters an error to continue. Use this
method to display a custom error dialog when an error occurs that you are unable to predict and report using try/catch.
Using try/catch
Enclose code that may be error prone within a try control structure. The following example shows a routine that opens and reads from a file enclosed in a try statement. If an execution error occurs in any of the statements after the start of the try control structure, the catch clause will be triggered with the details of the error. In the example below we declare a variable someError to contain details of the error.Tip: The data returned to the error routine is returned in the internal format that LiveCode uses to display execution errors. To look up the human friendly string associated with a particular error, look at the first item returned against the list of execution errors stored in the LiveCode IDE.Code: Select all
try open file tFile read from file tFile until eof close file catch someError answer "An error occurred reading a file" && someError end try
This will only work in the IDE.Code: Select all
put line (item 1 of someError) of the cErrorsList of card 1 of stack "revErrorDisplay"
If you want to include statements that will be run regardless of whether there has been an error or not, include the statements as part of a finally clause.
To create readable error messages for cases where you anticipate there may be an error, use the throw keyword. For example, if we want to display an error message when the result for opening a file returns something:In the example above, if the file cannot be opened and the result is set, the value of the result will be passed to the catch statement in the someError variable.Code: Select all
open file tFile if the result is not empty then throw the result
Writing a custom errorDialog routine
When an execution error occurs, an errorDialog message is sent. The IDE uses this message to display the execution error dialog. However you can write and include your own custom errorDialog routine. This is useful if you are planning to distribute your application. For example, you could create a stack that transmits the error information directly to your technical support department or displays a custom message on screen. A basic errorDialog routine is shown below:This routine will also be activated if you use the throw keyword to throw an error (outside of a try/catch control structure).Code: Select all
on errorDialog pError answer "There was an error" && pError end errorDialog
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
- VIP Livecode Opensource Backer
- Posts: 212
- Joined: Fri Feb 01, 2013 1:31 am
- Contact:
Re: Error log for Mobile
You are absolutely right! Thank you for showing me that. "ErrorDialogue" message will help a lot!
Cheers!
Thanks for the helpful info!
-Will
Cheers!
Thanks for the helpful info!
-Will