MooseX::Error::Trap - MooseX::Error::Trap documentation


MooseX-Error-Trap documentation  | view source Contained in the MooseX-Error-Trap distribution.

Index


SYNOPSIS

Top

Allows you to wrap any method in an eval and specify a dispatch method if the eval trips.

   package My::Test;
   use Moose;
   use MooseX::Error::Trap;

   trap 'some_method', 'what_to_do';
   sub some_method {
      ...
   }

   sub what_to_do {
      my ($self, $error) = @_;
      ...
   }

Exported Keyword

Top

trap

   trap 'wrapped_method', 'trap';

Will wrap any calls to 'wrapped_method' in an eval, and if that eval fails then 'trap' is run.

Currently 'trap' can be either a string or a CodeRef. The case for a code ref is simple if triped execute the code ref, passing $self and $@. When 'trap' is a string things are a bit more complicated. If 'trap' is the name of an attribute of $self we check to see what the type constraint is on that attr, if it's 'CodeRef' then we grab the value and proceede like a CodeRef. For any other type constraint we return the value of that attr. Lastly if 'trap' is the name of a method ($self->can($trap)) then we execute it passing $@ as the only param.

In any other case we just die with $@ as though the eval was not there.

TODO

Top

* A way to modify the relationship between the method run and the deferment method at runtime.

AUTHOR

Top

NOTBENH, <NOTBENH at cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-moosex-error-trap at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-Error-Trap. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

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

    perldoc MooseX::Error::Trap




You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-Error-Trap

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/MooseX-Error-Trap

* CPAN Ratings

http://cpanratings.perl.org/d/MooseX-Error-Trap

* Search CPAN

http://search.cpan.org/dist/MooseX-Error-Trap/

ACKNOWLEDGEMENTS

Top

Thanks again to team Moose.

COPYRIGHT & LICENSE

Top


MooseX-Error-Trap documentation  | view source Contained in the MooseX-Error-Trap distribution.