Merge branch 'abort-chain-doc-and-test' of https://github.com/melmothx/catalyst-runti...
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Exception / Interface.pm
CommitLineData
ede5238f 1package Catalyst::Exception::Interface;
2
2aba16c2 3use Moose::Role;
4use if !eval { require Moose; Moose->VERSION('2.1300') },
5 'MooseX::Role::WithOverloading';
80e287ba 6use namespace::clean -except => 'meta';
7
8use overload
9 q{""} => sub { $_[0]->as_string },
10 fallback => 1;
ede5238f 11
12requires qw/as_string throw rethrow/;
13
141;
b6c6af73 15
16__END__
17
18=head1 NAME
19
6d2a85aa 20Catalyst::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
37This is a role for the required interface for Catalyst exceptions.
38
39It ensures that all exceptions follow the expected interface,
40and adds overloading for stringification when composed onto a
41class.
42
43Note that if you compose this role onto another role, that role
44must 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
58Provided 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
72Catalyst Contributors, see Catalyst.pm
73
74=head1 COPYRIGHT
75
76This library is free software. You can redistribute it and/or modify
77it under the same terms as Perl itself.
78
79=cut