package TryCatch::Error;

use MooseX::FollowPBP;
use Moose;

=head1 NAME

TryCatch::Error - A simple error base class.

=head1 VERSION

Version 0.01


our $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).


has 'value'   => (
    is        => 'rw',
    isa       => 'Int',
    default   => 0,

has 'message' => (
    is        => 'rw',
    isa       => 'Str',
    default   => '',

no Moose;
no MooseX::FollowPBP;


=head2 new

Create a new error object:

    my $e = TryCatch::Error->new( value => $foo, message => bar );


=head2 get_*

=head2 set_*

The default TryCatch::Error has 2 attributes, B<value> and B<message>, which are an integer and a string.

=head1 AUTHOR

Pedro Figueiredo, C<< <me at> >>

=head1 BUGS

Please report any bugs or feature requests to C<bug-trycatch-error at>, or through the web interface at L<>.  I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc TryCatch::Error

You can also look for information at:

=over 4

=item * RT: CPAN's request tracker


=item * AnnoCPAN: Annotated CPAN documentation


=item * CPAN Ratings


=item * Search CPAN




=over 4

=item * Ash Berlin, the author of TryCatch

=item * The Moose crew



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.


45; # End of TryCatch::Error