You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Dan Lenski <dl...@gmail.com> on 2006/02/12 22:11:58 UTC

returning errors from Execute

I've recently learned to use the error-catching feature of Embperl'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 error message.

I would like to be able to do:

Execute({inputfile=>"foo.epl", errors=>\@errors});
foreach (@errors) {
if $_ eq

[7594]ERR:  24:  Error in Perl code: FIXME!! at
/home/dlenski/public_html/cms/communication_form.html line 18

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


RE: returning errors from Execute

Posted by Gerald Richter <ri...@ecos.de>.
> 
> On 2/12/06, Kathryn Andersen <ka...@katspace.homelinux.org> wrote:
> > 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.
> 
> I agree that this is easy to do in the case of errors which 
> are simply strings.  However I would like to be able to 
> return hash references as errors, such as
> with: croak \%error
> 
> The way that Execute returns errors right now, all I end up 
> with is the string representation HASH=0xdeadbeef.
> 

Sorry, but Embperl converts it to a string. There is currently no chance to
get the hash back.

Of course you can store the hash else where and return only a string and
retrive the hash from this other location.

E.g.

[-

$hashstore::error = \%hash ;
die "FIXME" ;

-]


And

foreach (@errors) {
    if (/FIXME/) {
      # respond to this error
	$hashstore::error -> holds the error
    }
}

That is not quite as elegant as returning hashs directly, but it should
work.

Gerald


 
** Virus checked by BB-5000 Mailfilter ** 


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


Re: returning errors from Execute

Posted by Dan Lenski <dl...@gmail.com>.
On 2/12/06, Kathryn Andersen <ka...@katspace.homelinux.org> wrote:
> 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.

I agree that this is easy to do in the case of errors which are simply
strings.  However I would like to be able to return hash references as
errors, such as
with: croak \%error

The way that Execute returns errors right now, all I end up with is
the string representation HASH=0xdeadbeef.

Dan

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


Re: returning errors from Execute

Posted by Kathryn Andersen <ka...@katspace.homelinux.org>.
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


Re: returning errors from Execute

Posted by Dan Lenski <dl...@gmail.com>.
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

Is there a way to change this behavior?  Thanks!

Dan Lenski

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