Hi
Good to see the log4perl-devel list up and alive. I've managed to drag
another company into using log4perl, but to business.
I've implemented Matt Sargants recomendations for exception handling but
on the throw method I keep getting a "bad file descriptor" in $@ when I
add the line Log::Log4perl->easy_init(); Is there a way around this? I
think it's the easy_init causing the problem; do I need to close
Log::Log4perl properly, or somesuch?
use MRFExceptions;
use Log::Log4perl;
Log::Log4perl->easy_init();
sub a {
my $test = shift;
if ($test) {
throw MRF::Exception::Remote('userid'=>"some crappy file");
}
}
my $test = 1;
local($@);
eval {
&a($test);
} or do {
print "ERROR "....@."\n";
if ($@) {
print "die, die, die\n";
if ($...@->isa('MRF::Exception::Deploy')) {
print "MRF::Exception::Deploy [", $...@->userid, "]: $@" ;
} else {
print "Down the list\n";
}
}
};
1;
And so
use Fatal qw(:void open close);
local $SIG{__DIE__} = sub {
my $err = shift;
if ($err->isa('MRF::Exception')) {
die $err; # re-throw
} else {
$! = "this error";
die MRF::Exception->new($err);
}
};
And so
package MRFExceptions;
our (@ISA, @EXPORT);
BEGIN {
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(throw); # symbols to export on request
}
use Exception::Class (
MRF::Exception => {
'description' => 'Default
Exception for the MRF system.',
},
MRF::Exception::IO => {
'isa' => 'MRF::Exception',
'description' => 'IO
Exception',
'fields' => [ 'filedump'],
},
MRF::Exception::Deploy => {
'isa' =>
'MRF::Exception',
'fields' => [
'operation','filedump' ],
'description' =>
'Deployment problem',
},
MRF::Exception::Remote => {
'isa' =>
'MRF::Exception::Deploy',
'fields' => [
'userid','machine','operation' ],
'description' =>
'Remote Deployment',
},
);
sub throw {
my $mess = join('', @_);
$mess =~ s/\n?$/\n/;
my $i = 1;
local $" = "', '";
package DB;
while (my @parts = caller($i++)) {
my $q; $q = "'" if @DB::args;
$mess .= " -> $parts[3](@DB::args)" .
" at $parts[1] line $parts[2]\n";
}
print "MESS: $mess\n";
die $mess;
}
1;
**********************************************************************
The Atradius Group conducts insurance, debt collection and information services
business through its registered offices and branch offices in various
countries. For information about the main registration details of the Atradius
branch offices in your country please visit
http://global.atradius.com/general-content/legal/legallist.html
IMPORTANT NOTICE. This message, including any and all attachments, is intended
for the addressee or its representative only and is confidential and may be
under legal privilege. Any form of unauthorised use, publication, reproduction,
copying or disclosure of the content of this e-mail is not permitted. If you
are not the intended recipient of this e-mail message and its contents, please
notify the sender immediately by reply email and delete this message and all
its attachments subsequently. Although this email and any attachments are
believed to be free of any virus or other defect that might affect any computer
system into which it is received and opened, it is the responsibility of the
recipient to ensure that it is virus free and no responsibility is accepted by
Atradius N.V. or its subsidiaries or affiliates (Atradius Group) either jointly
or severally, for any loss or damage arising in any way from its use. Email
messages received by Atradius Group can be stored for business purposes.
**********************************************************************
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel