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