I've got an application that needs to use
die [list, of, values]
to return a structured exception back up through to the handler. It
all works, even from code called from a Template coderef *except* when
an object is involved. Something mangles it to be
die "ARRAY(0x....) ..."
I'm betting it's XS Stash, but I don't know how to swap it to the
normal stash.
Here's a demo:
#!/usr/bin/env perl
use strict;
$|++;
BEGIN {
package Buggy;
sub new { bless {}, shift }
sub croak { my $self = shift; die @_ }
}
use Template;
my $tt = Template->new;
my %vars =
(
correct => sub { die @_ },
buggy => Buggy->new,
);
$tt->process(\*DATA, \%vars) or die $tt->error;
__END__
[% USE Dumper -%]
=== First, with a coderef: ===
[%
TRY;
correct(["hello", "there"]);
CATCH;
Dumper.dump(error);
END;
%]
=== Now, with an object: ===
[%
TRY;
buggy.croak(["hello", "there"]);
CATCH;
Dumper.dump(error);
END;
%]
This returns:
=== First, with a coderef: ===
$VAR1 = bless( [
'undef',
[
'hello',
'there'
],
\''
], 'Template::Exception' );
=== Now, with an object: ===
$VAR1 = bless( [
'undef',
'ARRAY(0x89f43c) at input file handle line 11, <DATA> line
1.
',
\''
], 'Template::Exception' );
Notice that with a coderef callback I get a nice arrayref there for
error.info. But with an object callback, I get a stringify instead.
Ooops.
Can we get an ETA on the fix?
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates