How to catch the error "revdberr,invalid connection id&

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

How to catch the error "revdberr,invalid connection id&

Post by bangkok » Sat Sep 06, 2008 7:54 pm

I would like to suppress the error message "revdberr,invalid connection id" (for instance when the Internet connection to a remote MySQL database is down)...

I tried the solution :

Code: Select all

on errorDialog pError
answer "There was an error" && pError
end errorDialog
to "catch" the error.

Nothing happens. I still get the error message.

However, with another type of error (for instance a button that tries to select a non existent field) then it works... The error message is catched.

Of course, The Script Debug Mode is false.

So, is the error "revdberr,invalid connection id" .... a special one ?

If yes, is it possible to suppress it ?

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

Post by Mark » Sat Sep 06, 2008 10:47 pm

BKK,

Code: Select all

revExecuteSQL blablabla
put the result into rslt
if item 1 of rslt contains "revdberr" then
  answer error rslt with "Okay"
else
  -- rest of script
end if
Best,

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

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Post by bangkok » Sun Sep 07, 2008 9:22 am

Thanks.

-Actually, I've noticed that revQueryDatabase gives a proper error message (via result) when the connection is lost (that was my concern)

-But still,

Code: Select all

on errorDialog 
doesn't catch the error

-However, with a revExecuteSQL command, then

Code: Select all

on errorDialog
is working

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

Post by Mark » Sun Sep 07, 2008 9:39 am

Hi bkk,

No that is not right. If the errorDialog message is sent, you probably have a mistake in your script. Database errors are always in the result or in the it variable, depending on which command or function you are using.

Best,

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

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Post by bangkok » Sun Sep 07, 2008 10:55 am

Mark wrote: No that is not right. If the errorDialog message is sent, you probably have a mistake in your script. Database errors are always in the result or in the it variable, depending on which command or function you are using.
Indeed, I was wrong. The

Code: Select all

onErrorDialog 
was fired by a mistake in the script (not related to database)

Okay, so now it's clear. Thanks for your help. :)

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Post by Janschenkel » Sun Sep 07, 2008 11:00 am

I seem to remember that the Rev team was considering 'throwing' some of the errors instead of returning them in 'it' or 'the result' - and I know that 'errorDialog' is called when there is a runtime error.
Have you tried wrapping your call to 'revExecuteSQL' in a try-catch block?

Code: Select all

on mouseUp
  -- do whatever preparation here
  ...
  try
    revExecuteSQL theConnction, theQuery
  catch tError
    answer error "Just caught a database error:" && tError with "OK"
  end try
end mouseUp
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Post by bangkok » Sun Sep 07, 2008 1:47 pm

Janschenkel wrote: Have you tried wrapping your call to 'revExecuteSQL' in a try-catch block?
Not yet. But that's a very good suggestion.

I'm in full "apprenticeship" right now... And actually I started to read stuff about "try-catch" yesterday while searching onErrorDialog infos.

I'll give it a try.

It's fascinating.

I was an old hypercard "amateur" long time ago... And I bought Runrev a few weeks ago... And since then, it's a daily marvel. No kidding.

The couple Runrev + MySQL (I start too) seems to be the total killer app.

:D

And i start to dream about an app' in RunRev that could mimic FileMaker Pro, with a MySQL database engine.

To draw "visual" relationships between tables like in FM 7, create "report" by adding fields on a "model" should be piece of cake with RunRev.

Anyway. I don't understand why RunRev doesn't have a larger "public footprint" if I may say. Probably a marketing and PR issue.

But that's another debate. :wink:

Post Reply

Return to “Databases”