Exception-Handler-1.004/ 0000755 0050712 0024461 00000000000 10543036576 015447 5 ustar tbutler mkgroup-l-d Exception-Handler-1.004/Changes 0000644 0050712 0024461 00000000741 10542620640 016732 0 ustar tbutler mkgroup-l-d Revision history for Perl extension Exception::Handler.pm
1.00_4
Thu Dec 21 18:04:23 CST 2006
Added new method ::error() to retrieve the contents of the most recently
thrown error in a given Exception::Handler object
1.00_3
Fri Sep 19 00:37:33 CDT 2003
Corrected slight grammatical/spelling error in stack dumps produced
by method Exception::Handler::trace()
1.00_2
12/23/02, 1:44 am
Initial release of Exception::Handler.pm
Exception-Handler-1.004/COPYING 0000644 0050712 0024461 00000000155 07712257244 016504 0 ustar tbutler mkgroup-l-d This library is free software, you may redistribute it and/or modify it
under the same terms as Perl itself.
Exception-Handler-1.004/Handler.pm 0000644 0050712 0024461 00000007345 10542620474 017366 0 ustar tbutler mkgroup-l-d package Exception::Handler;
use strict;
use vars qw( $VERSION );
$VERSION = 1.00_4; # Thu Dec 21 18:04:23 CST 2006
# --------------------------------------------------------
# Constructor
# --------------------------------------------------------
sub new {
my($this) = bless({ }, shift(@_));
$this->{'errors'} = [@_];
return $this
}
# --------------------------------------------------------
# Exception::Handler::error()
# --------------------------------------------------------
sub error { @{ $_->{'errors'} } } # very bad; very easy
# --------------------------------------------------------
# Exception::Handler::fail()
# --------------------------------------------------------
sub fail {
my($this) = shift(@_);
my($throw_count) = $this->{'tflag'} || 0;
{
# I refuse to manually initialize a standard environment
# variable. This is an example where the warnings pragma
# is going too far. It's something we live with.
local($^W) = undef;
# if we're running in a CGI gateway iface, we need
# to output the necessary HTTP headers
if ( $ENV{'REQUEST_METHOD'} ) {
print(<<__crash__) and exit;
Content-Type: text/html; charset=ISO-8859-1
PROCESS TERMINATED DUE TO ERRORS
@{[ $this->trace(@_) ]}
__crash__
}
else {
print(<<__crash__) and exit;
PROCESS TERMINATED DUE TO ERRORS
@{[ $this->trace(@_) ]}
__crash__
}
}
exit
}
# --------------------------------------------------------
# Exception::Handler::trace()
# --------------------------------------------------------
sub trace {
my($this) = shift(@_);
my(@errors) = @_; $this->{'errors'} = [@errors];
my($errfile) = '';
my($caught) = '';
my(
$pak, $file, $line, $sub,
$hasargs, $wantarray, $evaltext, $req_OR_use,
@stack, $i, $ialias
);
$ialias = 0;
while (
(
$pak, $file, $line, $sub,
$hasargs, $wantarray, $evaltext, $req_OR_use
) = caller( $i++ )
)
{
$ialias = $i - 2; next unless ($ialias > 0);
if ( (split(/\:\:/, $sub))[0] ne __PACKAGE__ ) {
push @stack, <<__ERR__
$ialias. $sub
-called at line ($line) of $file
@{[ ($hasargs)
? '-was called with args'
: '-was called without args' ]}
@{[ ($evaltext)
? '-was called to evalate text'
: '-was not called to evaluate anything' ]}
__ERR__
}
else {
$caught = qq[\012] . uc(qq[exception was raised at])
. qq[ line ($line) of $file];
}
}
$i = 0;
if ( scalar(@errors) == 0 ) {
push ( @errors, qq[[Unspecified error. Frame no. $ialias...]] );
}
foreach (@errors) {
$_ = ( defined($_) ) ? $_ : '';
if (!length($_)) { $_ = qq[Something is wrong. Frame no. $ialias...]; }
else {
$_ =~ s/^(?:\r|\n)//o; $_ =~ s/(?:\r|\n)$//o;
$_ = qq[\012$_\012];
}
++$i;
}
join(qq[\012] x 2, @errors)
. ($caught ? $caught . qq[\012] : '')
. qq[\012] . join(qq[\012] x 2, @stack);
}
# --------------------------------------------------------
# Exception::Handler::DESTROY()
# --------------------------------------------------------
sub DESTROY { } sub AUTOLOAD { }
1;
=pod
=head1 NAME
Exception::Handler - Report exceptions with formatted text call-stack
=head1 VERSION
1.00_2
=head1 @EXPORT, @EXPORT_OK
None.
=head1 Methods
new()
fail()
trace()
error()
=head2 AUTOLOAD-ed methods
None.
=head1 PREREQUISITES
None.
=head1 AUTHOR
Tommy Butler
=head1 COPYRIGHT
Copyright(c) 2001-2003, Tommy Butler. All rights reserved.
=head1 LICENSE
This library is free software, you may redistribute
and/or modify it under the same terms as Perl itself.
=cut
Exception-Handler-1.004/Makefile.PL 0000644 0050712 0024461 00000001202 07712257244 017415 0 ustar tbutler mkgroup-l-d use ExtUtils::MakeMaker;
require 5.6.0;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile
(
'ABSTRACT' => 'Report exceptions with formatted call-stack',
'AUTHOR' => 'Tommy Butler ',
'INSTALLDIRS' => 'site',
'NAME' => 'Exception::Handler',
'VERSION_FROM' => 'Handler.pm',
'linkext' => { LINKTYPE => '' }, # no link needed
'dist' =>
{
'COMPRESS' => 'gzip -9f',
'SUFFIX' => 'gz',
'ZIP' => '/usr/bin/zip',
'ZIPFLAGS' => '-rl',
}
);
Exception-Handler-1.004/MANIFEST 0000644 0050712 0024461 00000000275 07732513462 016604 0 ustar tbutler mkgroup-l-d COPYING
Changes
Handler.pm
MANIFEST
Makefile.PL
README
t/1_canuseit.t
t/2_isa.t
t/3_can.t
t/4_empty_subclass.t
META.yml Module meta-data (added by MakeMaker)
Exception-Handler-1.004/META.yml 0000644 0050712 0024461 00000000461 10543036576 016721 0 ustar tbutler mkgroup-l-d # http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Exception-Handler
version: 1.004
version_from: Handler.pm
installdirs: site
requires:
distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.17
Exception-Handler-1.004/README 0000644 0050712 0024461 00000002117 07732513274 016331 0 ustar tbutler mkgroup-l-d Exception::Handler version 1.00_3
=================================
DESCRIPTION
Report exceptions with formatted text call-stack
CHANGES IN LAST FEW RELEASES
(listed in reverse cronological order by date and subversion)
1.00_3
Fri Sep 19 00:37:33 CDT 2003
Corrected slight grammatical/spelling error in stack dumps produced
by method Exception::Handler::trace()
1.00_2
12/23/02, 1:44 am
Initial release of Exception::Handler.pm
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
On windows machines use nmake rather than make; those running cygwin don't have
to worry about this. If you don't know what cygwin is, use nmake and check out
after you're done installing this module if you want
to find out.
DEPENDENCIES
None.
AUTHOR
Tommy Butler
COPYRIGHT
Copyright (C) Tommy Butler 2001-2003, all rights reserved.
LICENCE
This library is free software, you may redistribute it and/or modify it
under the same terms as Perl itself.
Exception-Handler-1.004/t/ 0000755 0050712 0024461 00000000000 10543036576 015712 5 ustar tbutler mkgroup-l-d Exception-Handler-1.004/t/1_canuseit.t 0000644 0050712 0024461 00000000431 07712257244 020131 0 ustar tbutler mkgroup-l-d
use strict;
use Test;
# use a BEGIN block so we print our plan before MyModule is loaded
BEGIN { plan tests => 1, todo => [] }
# load your module...
use lib './';
use Exception::Handler;
# check object constructor
ok(ref(Exception::Handler->new()),'Exception::Handler');
exit; Exception-Handler-1.004/t/2_isa.t 0000644 0050712 0024461 00000000535 07712257244 017100 0 ustar tbutler mkgroup-l-d
use strict;
use Test;
# use a BEGIN block so we print our plan before MyModule is loaded
BEGIN { plan tests => 1, todo => [] }
BEGIN { $| = 1 }
# load your module...
use lib './';
use Exception::Handler;
my($f) = Exception::Handler->new();
# check to see if Exception::Handler ISA [foo, etc.]
ok(UNIVERSAL::isa($f,'Exception::Handler'));
exit; Exception-Handler-1.004/t/3_can.t 0000644 0050712 0024461 00000000722 07712257244 017064 0 ustar tbutler mkgroup-l-d
use strict;
use Test;
# use a BEGIN block so we print our plan before MyModule is loaded
BEGIN { plan tests => 6, todo => [] }
BEGIN { $| = 1 }
# load your module...
use lib './';
use Exception::Handler;
my($f) = Exception::Handler->new();
# check to see if non-autoloaded Exception::Handler methods are can-able ;O)
map { ok(ref(UNIVERSAL::can($f,$_)),'CODE') } qw
(
new
fail
trace
VERSION
DESTROY
AUTOLOAD
);
exit;
Exception-Handler-1.004/t/4_empty_subclass.t 0000644 0050712 0024461 00000001247 07712257244 021364 0 ustar tbutler mkgroup-l-d
use strict;
use Test;
# use a BEGIN block so we print our plan before module is loaded
BEGIN { use Exception::Handler }
BEGIN { plan tests => scalar(@Exception::Handler::EXPORT_OK), todo => [] }
BEGIN { $| = 1 }
# load your module...
use lib './';
# automated empty subclass test
# subclass Exception::Handler in package _Foo
package _Foo;
use strict;
use warnings;
use Exception::Handler qw( :all );
$Foo::VERSION = 0.00_0;
@_Foo::ISA = qw( Exception::Handler );
1;
# switch back to main package
package main;
# see if _Foo can do everything that Exception::Handler can do
map {
ok ref(UNIVERSAL::can('_Foo', $_)) eq 'CODE'
} @Exception::Handler::EXPORT_OK;
exit;