• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Catching undefined method in BeanShell

 
Renato Losio
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I'm playing around with bsh.

Need to know what's the exception thrown when a method does not exist and the invoke() is not implemented too. Is it just a generic EvalError or a subclass of it? ParseException or TargetError?

I would like to discriminate when the interface doesn't implement a method and control the message in my J2EE app: is there a way to know that from the exception thrown?

Cheers,

Renato
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouldn't this be possible to test relatively easily?
 
Renato Losio
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, and looks like it's indeed throwing a EvalError exception.

But I am bit puzzled with the BeanShell documentation (I was looking for a subclass of EvalError). And I haven't found a way yet to discriminate an undefined method from any different evalError.

So the question is: how can I find if a method is implemented in the bsh file or not?

Ok, I can get the string description of error message but I wouldn't like to base my code on that...

Renato
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Renato Losio:
So the question is: how can I find if a method is implemented in the bsh file or not?

Off the cuff, would it be feasible to read in the source of the bsf file and do a semi-reliable regex match?

Originally posted by Renato Losio:
Ok, I can get the string description of error message but I wouldn't like to base my code on that...

Well, at least that would be a simple solution and with a sensible default, it shouldn't be the end of the world even if the message changes upon a version upgrade.
 
Renato Losio
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>Well, at least that would be a simple solution and with a sensible default

OK, I will go for that. Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic