1 package Catalyst::Exception::Interface;
4 use if !eval { require Moose; Moose->VERSION('2.1300') },
5 'MooseX::Role::WithOverloading';
6 use namespace::clean -except => 'meta';
9 q{""} => sub { $_[0]->as_string },
12 requires qw/as_string throw rethrow/;
20 Catalyst::Exception::Interface - Role defining the interface for Catalyst exceptions
24 package My::Catalyst::Like::Exception;
26 use namespace::clean -except => 'meta';
28 with 'Catalyst::Exception::Interface';
30 # This comprises the required interface.
31 sub as_string { 'the exception text for stringification' }
32 sub throw { shift; die @_ }
33 sub rethrow { shift; die @_ }
37 This is a role for the required interface for Catalyst exceptions.
39 It ensures that all exceptions follow the expected interface,
40 and adds overloading for stringification when composed onto a
43 Note that if you compose this role onto another role, that role
44 must use L<MooseX::Role::WithOverloading>.
46 =head1 REQUIRED METHODS
66 =item L<Catalyst::Exception>
72 Catalyst Contributors, see Catalyst.pm
76 This library is free software. You can redistribute it and/or modify
77 it under the same terms as Perl itself.