X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FException%2FInterface.pm;h=73e4cc0df35818ff3b5f38f63189addca1911c25;hp=9b9c4219a8328eb3e58788911876029eddc4d0cd;hb=2aba16c216f81247154d5d2d1c20a6cbd85a3a3c;hpb=80e287baec94d765da86c3f208e8590a2b568060 diff --git a/lib/Catalyst/Exception/Interface.pm b/lib/Catalyst/Exception/Interface.pm index 9b9c421..73e4cc0 100644 --- a/lib/Catalyst/Exception/Interface.pm +++ b/lib/Catalyst/Exception/Interface.pm @@ -1,6 +1,8 @@ package Catalyst::Exception::Interface; -use MooseX::Role::WithOverloading; +use Moose::Role; +use if !eval { require Moose; Moose->VERSION('2.1300') }, + 'MooseX::Role::WithOverloading'; use namespace::clean -except => 'meta'; use overload @@ -10,3 +12,68 @@ use overload requires qw/as_string throw rethrow/; 1; + +__END__ + +=head1 NAME + +Catalyst::Exception::Interface - Role defining the interface for Catalyst exceptions + +=head1 SYNOPSIS + + package My::Catalyst::Like::Exception; + use Moose; + use namespace::clean -except => 'meta'; + + with 'Catalyst::Exception::Interface'; + + # This comprises the required interface. + sub as_string { 'the exception text for stringification' } + sub throw { shift; die @_ } + sub rethrow { shift; die @_ } + +=head1 DESCRIPTION + +This is a role for the required interface for Catalyst exceptions. + +It ensures that all exceptions follow the expected interface, +and adds overloading for stringification when composed onto a +class. + +Note that if you compose this role onto another role, that role +must use L. + +=head1 REQUIRED METHODS + +=head2 as_string + +=head2 throw + +=head2 rethrow + +=head1 METHODS + +=head2 meta + +Provided by Moose + +=head1 SEE ALSO + +=over 4 + +=item L + +=item L + +=back + +=head1 AUTHORS + +Catalyst Contributors, see Catalyst.pm + +=head1 COPYRIGHT + +This library is free software. You can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut