Errors with offending parts listed.

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderator: Klaus

Post Reply
kcorey
Posts: 62
Joined: Fri Nov 25, 2011 6:06 pm

Errors with offending parts listed.

Post by kcorey » Fri Feb 03, 2012 12:39 am

In one of my stacks I'm using the skinning code that David demonstrated in the Games Academy.

Pretty cool stuff, until it all goes wrong.

"can't find card".

Huh...that's strange. The card is *there*. When I type it in the message box it works. What gives?

I finally twigged that the name of the skin card is kept in a custom property cSkin. Somehow, instead of 'skin' it was 'skin '. Of course there was no card called that.

Can the error messages please list the offending bit like this:

can't find card "skin "

I know this would be too big a job to implement retrospectively right now, but going forward error messages shouldn't just be on line x, char y, they should give slightly more of a clue to us clueless.

Thanks,

-Ken

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Errors with offending parts listed.

Post by Mark » Sat Feb 04, 2012 8:57 pm

Hi,

The name of the card is not included to make programming easier. If the name were included, the error were different each time a card couldn't be found. Without the name, you can always write the same:

Code: Select all

go cd x
if the result is  "can't find card" then
  beep
  answer error "Card" && x && "cannot be found." with "OK"
end if
This way, you can always know which card can't be found.

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

kcorey
Posts: 62
Joined: Fri Nov 25, 2011 6:06 pm

Re: Errors with offending parts listed.

Post by kcorey » Mon Feb 06, 2012 8:44 am

To directly answer your post, you could always do this:
if char 1 to 15 of the result is "can't find card" then

I think you'll agree that's hardly a burden compared to the benefit.

However, you bring up a larger issue: internationalisation. Is the error in fact "can't find card" even if the language setting of the device is Finnish, Japanese, Urdu?

Seems to me a "proper" way to be able to handle errors programatically is to provide access to the numbers already internal to LiveCode (the first argument to errorDialog).

So then the code reduces to:
if errorCode=225 then
-- some error handling here.

Which would be more likely to work in more languages.

-Ken

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Errors with offending parts listed.

Post by Mark » Mon Feb 06, 2012 10:52 am

Hi Ken,

Yes, the errors are always the same. Actually, one could argue that they are not in English but in the LiveCode language.

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

Post Reply