Commit | Line | Data |
ede5238f |
1 | package Catalyst::Exception::Interface; |
2 | |
2aba16c2 |
3 | use Moose::Role; |
4 | use if !eval { require Moose; Moose->VERSION('2.1300') }, |
5 | 'MooseX::Role::WithOverloading'; |
80e287ba |
6 | use namespace::clean -except => 'meta'; |
7 | |
8 | use overload |
9 | q{""} => sub { $_[0]->as_string }, |
10 | fallback => 1; |
ede5238f |
11 | |
12 | requires qw/as_string throw rethrow/; |
13 | |
14 | 1; |
b6c6af73 |
15 | |
16 | __END__ |
17 | |
18 | =head1 NAME |
19 | |
6d2a85aa |
20 | Catalyst::Exception::Interface - Role defining the interface for Catalyst exceptions |
b6c6af73 |
21 | |
22 | =head1 SYNOPSIS |
23 | |
24 | package My::Catalyst::Like::Exception; |
25 | use Moose; |
26 | use namespace::clean -except => 'meta'; |
a62b43cd |
27 | |
6d2a85aa |
28 | with 'Catalyst::Exception::Interface'; |
29 | |
b6c6af73 |
30 | # This comprises the required interface. |
31 | sub as_string { 'the exception text for stringification' } |
96bd9dbe |
32 | sub throw { shift; die @_ } |
33 | sub rethrow { shift; die @_ } |
a62b43cd |
34 | |
b6c6af73 |
35 | =head1 DESCRIPTION |
36 | |
37 | This is a role for the required interface for Catalyst exceptions. |
38 | |
39 | It ensures that all exceptions follow the expected interface, |
40 | and adds overloading for stringification when composed onto a |
41 | class. |
42 | |
43 | Note that if you compose this role onto another role, that role |
44 | must use L<MooseX::Role::WithOverloading>. |
45 | |
46 | =head1 REQUIRED METHODS |
47 | |
48 | =head2 as_string |
49 | |
50 | =head2 throw |
51 | |
52 | =head2 rethrow |
53 | |
54 | =head1 METHODS |
55 | |
56 | =head2 meta |
57 | |
58 | Provided by Moose |
59 | |
6d2a85aa |
60 | =head1 SEE ALSO |
61 | |
62 | =over 4 |
63 | |
64 | =item L<Catalyst> |
65 | |
66 | =item L<Catalyst::Exception> |
67 | |
68 | =back |
69 | |
b6c6af73 |
70 | =head1 AUTHORS |
71 | |
72 | Catalyst Contributors, see Catalyst.pm |
73 | |
74 | =head1 COPYRIGHT |
75 | |
76 | This library is free software. You can redistribute it and/or modify |
77 | it under the same terms as Perl itself. |
78 | |
79 | =cut |