Hi, On 1/26/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Exceptions thrown by java code are placed in $@ if the code is called inside > an eval block. > The exceptions seem to have a very limited lifespan when left in [EMAIL > PROTECTED] If I > copy $@ to a normal variable I can > call multiple functions , if I use $@ directly the second function call fails > with "can't call method "something" > without a package or object reference" > > Is this related to the way perl normally handles $@ , something I missed in > the Inline::Java docs or an Inline::Java bug? > > eg : > > eval { call_some_java() } > if($@) > { > [EMAIL PROTECTED]>getMessage(); > [EMAIL PROTECTED]>getMessage(); > } > > fail but
When you call [EMAIL PROTECTED]>getMessage(), it in turn has eval{} statements inside it somewhere, thereby resetting the $@ globlal variable. It's best to use a temporary variable to store the exception if you are going to call methods on it. I will add a comment about that in the docs. Patrick > > eval { call_some_java() } > if($@) > { > my $var = $@; > $var->getMessage(); > $var->getMessage(); > } > > works > > -- ===================== Patrick LeBoutillier Laval, Québec, Canada