Hi, I'm working on a module to provide some syntactic sugar for creating exceptions with throw/catch semantics in a Moose-ish way. The basic idea is:
package MyApp; use Moose; use MooseX::Exceptions; exception 'MyApp::Ex::Foo' => ( error => 'A foobar exploded' ); exception 'MyApp::Ex::Bar' => ( error => 'barf', extends => 'MyApp::Ex::Foo' ); sub do_something { ... throw MyApp::Ex::Foo; # or throw MyApp::Ex::Foo => 'custom error message'; } sub catcher { my $self = shift; eval { $self->do_something; } if ( my $e = catch 'MyApp::Ex::Foo' ) { # exception isa MyApp::Ex::Foo # or if ( my $e = catch ) { # catch anything .... throw $e; # rethrow exception object; } I haven't implemented all the features that I want just yet, and I'm pretty new to Moose and Class::MOP. So I'd love to hear any suggestions from the community regarding feature ideas and ways to improve my code. The woefully incomplete code and POD as it currently exists can be found here: code: http://www.friedo.com/MooseX-Exceptions/lib/MooseX/Exceptions.pm POD: http://www.friedo.com/MooseX-Exceptions/lib/MooseX/Exceptions.html There aren't any real unit tests or anything yet. I hope to have something CPAN-worthy in a week or two, depending on how much time I have to work on it. Thanks for any comments. Mike