try catch question

Questions, tips and tricks and techniques for scripting in Servoy

try catch question

Postby jdbruijn » Mon Aug 29, 2011 2:39 pm

I'm using the following code for my try catch:
Code: Select all
try { ... }
catch (e){
    var reason = e.rhinoException.getMessage();
}

This code does work, but it shows a warning buildmarker in Servoy 6: The property rhinoException is undefined in e
What is the correct notation for this in Servoy 6?

Jos
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 480
Joined: Sun Apr 11, 2010 6:34 pm

Re: try catch question

Postby jcompagner » Wed Aug 31, 2011 11:54 am

.rhinoException is really specific and sort of internal

but what you can do is:


Code: Select all
var reason = e['rhinoException'].getMessage();


what is wrong with:

Code: Select all
e.message


not enough info?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8284
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: try catch question

Postby jdbruijn » Wed Aug 31, 2011 12:10 pm

jcompagner wrote:what is wrong with:

Code: Select all
e.message


not enough info?

ignorance on my part ;)
But when I use that code it also gives me a warning buildmarker:
The property message is undefined in e
Code: Select all
try { ... }
catch (e){
    var reason = e.message;
}


Jos
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 480
Joined: Sun Apr 11, 2010 6:34 pm

Re: try catch question

Postby jcompagner » Wed Aug 31, 2011 12:44 pm

yes, that will be fixed in a next release of servoy.
now an exception object that you have in the catch(e) block will have 2 properties: name and message
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8284
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: try catch question

Postby tgs » Fri Sep 23, 2011 11:00 am

Hi Johan!
jcompagner wrote:yes, that will be fixed in a next release of servoy.

Is it fixed in 6.0.1?
jcompagner wrote:now an exception object that you have in the catch(e) block will have 2 properties: name and message

I'm sorry, but this is not really clear for me. Would you please so kind to explain it a little bit more? How should be the type declaration for the catch(e)?
Thomas Schnaus
SAN Developer
yomotec GmbH
User avatar
tgs
 
Posts: 883
Joined: Wed Oct 04, 2006 12:05 pm
Location: Germany

Re: try catch question

Postby jcompagner » Fri Sep 23, 2011 11:11 am

yes this is fixed in 6.0.1

if you do this:

try {

}
catch(e) {
e.
}

then you see you will have code completion behind e.

Servoy typed 'e' for you
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8284
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: try catch question

Postby tgs » Fri Sep 23, 2011 11:42 am

jcompagner wrote:then you see you will have code completion behind e.

Servoy typed 'e' for you

I'm on Servoy 6.0.1 and I have tried this in a new method, but I get no code completions behind the e.!? Except the error 'No completions available'.
Thomas Schnaus
SAN Developer
yomotec GmbH
User avatar
tgs
 
Posts: 883
Joined: Wed Oct 04, 2006 12:05 pm
Location: Germany

Re: try catch question

Postby jcompagner » Fri Sep 23, 2011 11:56 am

yes you are right, that fix was done on 31/8 but the dltk build servoy 6.0.1 uses is from 25/8, so it didn't came in this release.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8284
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Methods

Who is online

Users browsing this forum: No registered users and 2 guests