Exception-Handler-1.004/0000755005071200244610000000000010543036576015447 5ustar tbutlermkgroup-l-dException-Handler-1.004/Changes0000644005071200244610000000074110542620640016732 0ustar tbutlermkgroup-l-dRevision 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/COPYING0000644005071200244610000000015507712257244016504 0ustar tbutlermkgroup-l-dThis library is free software, you may redistribute it and/or modify it under the same terms as Perl itself. Exception-Handler-1.004/Handler.pm0000644005071200244610000000734510542620474017366 0ustar tbutlermkgroup-l-dpackage 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.PL0000644005071200244610000000120207712257244017415 0ustar tbutlermkgroup-l-duse 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/MANIFEST0000644005071200244610000000027507732513462016604 0ustar tbutlermkgroup-l-dCOPYING 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.yml0000644005071200244610000000046110543036576016721 0ustar tbutlermkgroup-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/README0000644005071200244610000000211707732513274016331 0ustar tbutlermkgroup-l-dException::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/0000755005071200244610000000000010543036576015712 5ustar tbutlermkgroup-l-dException-Handler-1.004/t/1_canuseit.t0000644005071200244610000000043107712257244020131 0ustar tbutlermkgroup-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.t0000644005071200244610000000053507712257244017100 0ustar tbutlermkgroup-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.t0000644005071200244610000000072207712257244017064 0ustar tbutlermkgroup-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.t0000644005071200244610000000124707712257244021364 0ustar tbutlermkgroup-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;