Skip to main content.
home | support | download

Back to List Archive

Re: Avoiding errors for missing properties

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Thu Jul 08 2004 - 15:24:04 GMT
On Thu, Jul 08, 2004 at 06:37:24AM -0700, Tac wrote:
> How can I stop an error from trying to get a non-existent property from the
> perl API?  I'm particular, I have
>  
>             $result->Property( "year" ),

Will this work?

    eval { $prop = $result->Property('year') };
    warn "Failed to get property 'year': $@\n"
        if $@;


> 
> but sometimes I don't have a "year" Property.  This happens often now,
> because the big indexes take hours and hours to run, so I test stuff with
> the small indexes, but I don't want to break searching the big indexes.
> Having it return blank or "UNDEFINED" is fine, but aborting is no good.  Is
> there a way around this?

Not too long ago I added this behavior.  I think aborting is correct
because you are asking for invalid data according to the index.  Trap
with eval {} if you think you might be doing something that causes an
exception.

-- 
Bill Moseley
moseley@hank.org

Unsubscribe from or help with the swish-e list: 
   http://swish-e.org/Discussion/

Help with Swish-e:
   http://swish-e.org/current/docs
   swish-e@sunsite.berkeley.edu
Received on Thu Jul 8 08:24:25 2004