| TryCatch-Error documentation | Contained in the TryCatch-Error distribution. |
TryCatch::Error - A simple error base class.
Version 0.01
This module provides a building block to writing your own error objects, to use with TryCatch (or some similar module).
It enables you to write things like this, straight away:
use TryCatch::Error;
use TryCatch;
try {
# ...
# something that can go horribly wrong
if ( $error_condition ) {
die TryCatch::Error->new( value => $foo, message => $bar );
}
}
catch ( TryCatch::Error $e ) {
print STDERR 'Ooops: ', $e->get_message, ' with ', $e->get_value;
}
TryCatch::Error can be sub-classed to create your own errors (possibly containing more detail, see t/03-subclassing.t for an example).
Create a new error object:
my $e = TryCatch::Error->new( value => $foo, message => bar );
The default TryCatch::Error has 2 attributes, value and message, which are an integer and a string.
Pedro Figueiredo, <me at pedrofigueiredo.org>
Please report any bugs or feature requests to bug-trycatch-error at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=TryCatch-Error. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc TryCatch::Error
You can also look for information at:
Copyright 2009 Pedro Figueiredo, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| TryCatch-Error documentation | Contained in the TryCatch-Error distribution. |
package TryCatch::Error; use MooseX::FollowPBP; use Moose;
our $VERSION = '0.01';
has 'value' => ( is => 'rw', isa => 'Int', default => 0, ); has 'message' => ( is => 'rw', isa => 'Str', default => '', ); __PACKAGE__->meta->make_immutable; no Moose; no MooseX::FollowPBP;
45; # End of TryCatch::Error