Bric::Util::Fault - base class for all Exceptions
$Revision: 1.8 $
$Date: 2002/08/30 22:13:41 $
eval {
# Do something that causes general mayhem.
die Bric::Util::Fault::Subclass->new({ msg => 'Ro-ro!' });
};
if (my $err = $@) {
print "Oh-oh, something faulted. Let's look at it...";
print "Type: ", ref $err, "\n";
print "Message: ", $err->get_msg, "\n";
print "Payload: ", $err->get_payload, "\n";
print "Timestamp: ", $err->get_timestamp, "\n";
print "Package: ", $err->get_pkg, "\n";
print "Filename: ", $err->get_filename. "\n";
print "Line" ", $err->get_line, "\n";
print "Stack:\n";
foreach my $c (@{ $err->get_stack }) {
print "\t", (ref $c ? join(' - ', @{$c}[1,3,2]) : $c), "\n";
}
print "Environment:\n";
while (my ($k, $v) = each %{ $err->get_env }) {
print "\t$k => $v\n";
}
}
Bric::Util::Fault is the base class for all Bricolage Exceptions. Do not use this class directly if you are looking for an exception to throw. Rather, look at Bric::Util::Fault::Exception.
Whereas earlier perl versions could only die ('string'), perl 5.005 and beyond can die ($obj). This object can contain rich state information which enables the calling eval {} to perform more varied object introspection. This also avoids the proliferation of error strings, and makes catching errors very simple.
Creates a new Fault object for processing up the caller stack
Keys of $init are:
The exception message.
Extra error information, e.g., from $! or $@.
Throws:
Um, this can't really throw itself. or can it? i dunno.
Side Effects: NONE.
Notes:
This method should only be used within a 'die' context, and one of its subclasses should be thrown instead.
Dummy method to prevent wasting time trying to AUTOLOAD DESTROY.
Returns error string of type "pkg -- filename -- line -- msg". Also called when the exception object is used in a string context.
Throws: NONE.
Side Effects: NONE.
Notes: Overloads the double-quoted string operator.
Returns the message set by the programmer at error time.
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
Returns the timestamp of the error. The timestamp is the epoch time of the error - the number of seconds since January 1, 1970.
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
Returns a hash reference of the contents of %ENV at time of error.
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
Returns the name of the file in which the error ocurred.
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
Return the line number at which the error ocurred in the file returned by get_filename().
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
Returns the name of the package in which the error ocurred.
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
Returns the programmer-specified payload.
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
Returns the stack trace.
Throws: NONE.
Side Effects: NONE.
Notes: NONE.
#------------------------------------------------------------------------------#
NONE.
NONE.
NONE.
This is the only class file that should use the die operator. Everyone else should use the interface specified above.
matthew d. p. k. strelchun-lanier - matt@lanier.org
Bric, Bric::Util::Fault::Exception
Hey! The above document had some coding errors, which are explained below:
You forgot a '=back' before '=head2'
'=item' outside of any '=over'
You forgot a '=back' before '=head2'
'=item' outside of any '=over'