CPANPLUS::Error - Error handling for the CPAN++ interface |
stack()
list()
flush([NUMBER])
forget([NUMBER])
CPANPLUS::Error - Error handling for the CPAN++ interface
use CPANPLUS::Error;
my $obj = new CPANPLUS::Error( error_track => 1, error_level => 2, message_track => 0, message_level => 1, );
$obj->trap( error => 'There was an error!'); $obj->inform(msg => 'I did something', quiet=>1);
my @all_errors = $obj->stack(); my $last_msg = $obj->list();
my $last_two_errors = $obj->flush(2); my $all_messages = $obj->forget();
my $msg_and_err = summarize(all => 1);
CPANPLUS::Error provides a standard method of handling errors for components of the CPAN++ interface.
The constructor expects a hash of arguments for the following fields:
0 no action
1 Carp ('warn')
2 Croak ('die')
> 2 Confess ('die with a stacktrace')
This method puts the error message on the error stack. The optional 'quiet' argument will override the error_level setting and prevent error actions from being taken. 1 is returned for success in handling the error; 0 is returned otherwise.
This function behaves like trap()
except that it manipulates
messages instead of errors. It returns 1 if the message was
handled, and 0 if it was not.
stack()
If called in list context, stack()
returns the contents of the
error stack. If called in scalar context, it returns the most
recent error.
list()
In list context, this method returns the message stack. In scalar context it returns the most recent message.
flush([NUMBER])
Flush removes the specified number of errors from the error stack and returns an array reference containing the removed errors. If no argument is specified, the entire stack is emptied.
forget([NUMBER])
This method is like flush()
except that it operates on the
message stack.
This method allows errors and messages to be combined in the order in which they were logged. If no argument is specified, error is assumed. It accepts the following keys:
An array reference containing the results is returned.
Copyright (c) 2001, 2002 Jos Boumans <kane@cpan.org> and Ann Barcomb <kudra@cpan.org>. All rights reserved.
This documentation Copyright (c) 2002 Ann Barcomb <kudra@cpan.org>.
This library is free software; you may redistribute and/or modify it under the same terms as Perl itself.
CPANPLUS::Error - Error handling for the CPAN++ interface |