Acme-JavaTrace
view release on metacpan or search on metacpan
DESCRIPTION
<buzzword> This module tries to improves the Perl programmer
experience by porting the Java paradigm to print stack traces,
which is more professional than Perl's way. </buzzword>
This is achieved by modifying the functions warn() and die()
in order to replace the standard messages by complete stack traces
that precisely indicates how and where the error or warning occurred.
Other than this, their use should stay unchanged, even when using
die() inside eval().
For a explanation of why I wrote this module, you can read the sildes
of my lightning talk "Entreprise Perl", available here:
http://maddingue.org/conferences/yapc-eu-2004/entreprise-perl/
INSTALLATION
lib/Acme/JavaTrace.pm view on Meta::CPAN
Acme::JavaTrace - Module for using Java-like stack traces
=head1 VERSION
Version 0.08
=head1 SYNOPSIS
On the command-line:
perl -wMAcme::JavaTrace program_with_strange_errors.pl
Inside a module:
use Acme::JavaTrace;
warn "some kind of non-fatal exception occured";
die "some kind of fatal exception occured";
=head1 DESCRIPTION
C<< <buzzword> >>This module tries to improves the Perl programmer
experience by porting the Java paradigm to print stack traces, which
is more professional than Perl's way. C<< </buzzword> >>
This is achieved by modifying the functions C<warn()> and C<die()>
in order to replace the standard messages by complete stack traces
that precisely indicates how and where the error or warning occurred.
Other than this, their use should stay unchanged, even when using
C<die()> inside C<eval()>.
For a explanation of why I wrote this module, you can read the slides
of my lightning talk I<Entreprise Perl>, available here:
L<http://maddingue.org/conferences/yapc-eu-2004/entreprise-perl/>
=head1 OPTIONS
t/03showrefs0.t view on Meta::CPAN
use strict;
use Test::More tests => 4;
use Acme::JavaTrace;
my $text = "Advice from Klortho #11901: You can't just make shit up and expect the computer to know what you mean, Retardo!";
eval {
die bless { type => 'error', text => $text }, 'Exception'
};
isa_ok( $@, 'HASH' );
isa_ok( $@, 'Exception' );
is( $@->{text}, $text, "checking the field text" );
is( $@->{type}, 'error', "checking the field text" );
t/03showrefs1.t view on Meta::CPAN
use strict;
use Test::More tests => 1;
use Acme::JavaTrace 'showrefs';
use Data::Dumper;
my $text = "Advice from Klortho #11901: You cant just make shit up and expect the computer to know what you mean, Retardo!";
my @attrs = (
$Data::Dumper::VERSION <= 2.121
? (text => $text)
: (type => 'error', text => $text)
);
eval {
die bless { @attrs }, 'Exception'
};
like( $@,
qq|/^Caught exception object: Exception=HASH\\(0x[0-9a-fA-F]+\\): bless\\( \\{\n|.
qq|\\s+'text' => '\Q$text\E',?\n|.
($Data::Dumper::VERSION <= 2.121 ? '' : qq|\\s+'type' => 'error',?\n|) .
qq|\\}, 'Exception' \\)/|,
"checking the trace"
);
( run in 0.434 second using v1.01-cache-2.11-cpan-65fba6d93b7 )