perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kathryn Andersen <kat_li...@katspace.homelinux.org>
Subject Re: returning errors from Execute
Date Sun, 12 Feb 2006 22:10:03 GMT
On Sun, Feb 12, 2006 at 04:15:03PM -0500, Dan Lenski wrote:
> I've recently learned to use the error-catching feature of
> Embperl::Object's Execute command.  The thing I'm wondering is if it's
> possible to make it return just the string or object that I pass to
> the croak/die command, rather than the complete Embperl error message.
> 
> I would like to be able to do:
> 
> # base.html
> Execute({inputfile=>"*", errors=>\@errors});
> foreach (@errors) {
>   if ($_ eq "FIXME") {
>     # respond to this error
>   }
> }
> 
> # foo.html
> [- die "FIXME"; -]
> 
> But right now, the error array gets filled with long hard-to-parse
> strings such as:
> 
> [7594]ERR:  24:  Error in Perl code: FIXME!! at /foo/bar/baz/foo.html line 1
> 
Why is that hard to parse?  Use perl regular expressions, that's one of
the things it is good at.

You'd just have to go

foreach (@errors) {
   if (/FIXME/) {
     # respond to this error
   }
}

That should enable you to respond to all the "FIXME" errors.

Kathryn Andersen
-- 
 _--_|\     | Kathryn Andersen	<http://www.katspace.com>
/      \    | 
\_.--.*/    | GenFicCrit mailing list <http://www.katspace.com/gen_fic_crit/>
      v     | 
------------| Melbourne -> Victoria -> Australia -> Southern Hemisphere
Maranatha!  |	-> Earth -> Sol -> Milky Way Galaxy -> Universe

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message