ErrorDialog handler

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

ErrorDialog handler

Post by ittarter » Fri Apr 28, 2017 4:23 pm

Hello,

So I'm trying to get major application crashes to be automatically added to a database for review. (I've learned that users generally don't report them, and when they do they usually don't give much useful information)

I read that the errorDialog is the way to custom handle application crashes. However it's tricky to test, since when working in livecode crashes are handled differently.

On a standalone program (Windows, Livecode 8.1.2) I can get the answer "test" but not tError (see code below). No second dialog box pops up at all, surprisingly.

Do I have to setup stack "revErrorDisplay" myself? Are my variables somehow bad? I thought I believe I duly copied what the dictionary said...

Thanks in advance

Code: Select all

on errorDialog pExecutionError, parseError
   answer "test"
   put line (item 1 of line 1 of pExecutionError) of the cErrorsList of card 1 of stack "revErrorDisplay" into tDescription
   put pExecutionError & return & tDescription & return & parseError into tError
   answer tError
end errorDialog
p.s. lockErrorDialogs is false

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: ErrorDialog handler

Post by jacque » Sat Apr 29, 2017 8:04 pm

The errors list exists only in the IDE and is not included in a standalone. If you need to use it, you have to store it in the stack yourself. I'd make a custom property somewhere in your stack that contains the list and reference that when you need to look up an error code. Note that in LC 8 the list was removed from stack "revErrorDisplay" and is now an IDE property named "scriptExecutionErrors".

If you want to find it no matter what version of LC you are running, this works:

Code: Select all

put the cErrorsList of cd 1 of stack "revErrorDisplay" into tList
if tList = "" or the result <> "" then
  put the scriptExecutionErrors into tList
end if
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Re: ErrorDialog handler

Post by ittarter » Sun Apr 30, 2017 10:21 am

Thank you Jacque! I'm very excited to try this out :)

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Re: ErrorDialog handler

Post by ittarter » Sun Apr 30, 2017 11:59 am

So I've tried the scriptExecutionErrors about a dozen times (LC 8 still), with and without including the pre-LC 8 code you gave me, and the variable
is always empty. BUT when I cause an application crash without my handler errorDialog active, I get this wonderful explanation:

Code: Select all

Executing at 12:56:19 PM on Sunday, April 30, 2017
Type: Chunk: no such object
Object: button "Crash" of card "Default" of stack "C:/Users/ittar/Desktop/test/UberLingua.exe"
Line: put x into fld "test"
Line Num: 2
Hint: mouseUp

Comments: 
Where is this explanation stored, if not in scriptExecutionErrors?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: ErrorDialog handler

Post by jacque » Sun Apr 30, 2017 9:18 pm

I probably wasn't clear enough. The list of error messages returned from either the old card-based location or the new property are identical, but the list consists of only error numbers followed by a short description. If you go to the Sample Stacks area (click on the icon in the LC toolbar) and search for "LiveCode error lookup" you will find a stack that Richard and I made to show you the list and let you look up the numbers. It's a handy reference for debugging standalones.

ErrorDialog only returns those error numbers, which your script would have to look up by consulting a list you've stored in your stack. But LC has always offered to provide the more complete error info if you have Bug Reports checked in standalone settings. It sounds like you've done that, so by trapping errorDialog you've prevented LC from handling the lookup. If the goal is to log the errors somewhere, then you could log the error number and pass errorDialog so that LC can finish managing the display to the user.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Re: ErrorDialog handler

Post by ittarter » Mon May 01, 2017 9:50 am

Thanks for pointing me toward that sample stack, Jacque.

It was actually

Code: Select all

on errorDialog ExecutionError
   if ExecutionError <> empty then
      answer ExecutionError
   end if
that finally got me the information that livecode uses to produce the Error dialog window. I was never able to get any information from scriptExecutionErrors.

So I can use that along with the error lookup information from the sample stack to do exactly what I want! Thank you so much!

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”