Subj : Re: try catch blocks To : Amit Lonkar From : Brendan Eich Date : Thu May 15 2003 10:36 am This is a multi-part message in MIME format. --------------030505040704050302080201 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Amit Lonkar wrote: > Hi all, > > I have a js file in which i am embedding some java code > > i want to put a try catch block in it as > > try > { > } > catch(SQLException ex) > { > } > finally > { > } > > Can some one please tll me the syntax to be used for this in the js file.? > > I get the error as "Exception: invalid catch block condition" Per ECMA-262, finally is supported in JS, as Igor pointed out. SpiderMonkey supports an extension to ECMA: catch guards. If you write try { . . . } catch (e if e instanceof SQLException) { // here we know e is an SQLException } catch (e) { // this is the "catch-all" clause } finally { // code here runs no matter how control leaves the try-catch chain } I don't recall whether Rhino supports this extension. /be --------------030505040704050302080201 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Amit Lonkar wrote:
Hi all,
 
I have a js file in which i am embedding some java code
 
i want to put a try catch block in it as
 
try
{
}
catch(SQLException ex)
{
}
finally
{
}
 
Can some one please tll me the syntax to be used for this in the js file.?
 
I get the error as "Exception: invalid catch block condition"

Per ECMA-262, finally is supported in JS, as Igor pointed out.

SpiderMonkey supports an extension to ECMA: catch guards.  If you write

  try {
    . . .
  } catch (e if e instanceof SQLException) {
    // here we know e is an SQLException
  } catch (e) {
    // this is the "catch-all" clause
  } finally {
    // code here runs no matter how control leaves the try-catch chain
  }

I don't recall whether Rhino supports this extension.

/be

--------------030505040704050302080201-- .