Commit | Line | Data |
---|---|---|
a2f2cde9 | 1 | package Catalyst::Exception; |
2 | ||
3cdcf968 | 3 | # XXX: See bottom of file for Exception implementation |
a2f2cde9 | 4 | |
5 | package Catalyst::Exception::Base; | |
6 | ||
3cdcf968 | 7 | use Moose; |
a2f2cde9 | 8 | use Carp (); |
9 | ||
10 | =head1 NAME | |
11 | ||
12 | Catalyst::Exception - Catalyst Exception Class | |
13 | ||
14 | =head1 SYNOPSIS | |
15 | ||
16 | Catalyst::Exception->throw( qq/Fatal exception/ ); | |
17 | ||
18 | See also L<Catalyst>. | |
19 | ||
20 | =head1 DESCRIPTION | |
21 | ||
22 | This is the Catalyst Exception class. | |
23 | ||
24 | =head1 METHODS | |
25 | ||
b5ecfcf0 | 26 | =head2 throw( $message ) |
a2f2cde9 | 27 | |
b5ecfcf0 | 28 | =head2 throw( message => $message ) |
ebfde331 | 29 | |
b5ecfcf0 | 30 | =head2 throw( error => $error ) |
a2f2cde9 | 31 | |
32 | Throws a fatal exception. | |
33 | ||
34 | =cut | |
35 | ||
36 | sub throw { | |
37 | my $class = shift; | |
38 | my %params = @_ == 1 ? ( error => $_[0] ) : @_; | |
39 | ||
40 | my $message = $params{message} || $params{error} || $! || ''; | |
41 | ||
42 | local $Carp::CarpLevel = 1; | |
43 | ||
44 | Carp::croak($message); | |
45 | } | |
46 | ||
3cdcf968 | 47 | =head2 meta |
48 | ||
49 | Provided by Moose | |
50 | ||
2f381252 | 51 | =head1 AUTHORS |
a2f2cde9 | 52 | |
2f381252 | 53 | Catalyst Contributors, see Catalyst.pm |
a2f2cde9 | 54 | |
55 | =head1 COPYRIGHT | |
56 | ||
57 | This program is free software, you can redistribute it and/or modify | |
58 | it under the same terms as Perl itself. | |
59 | ||
60 | =cut | |
61 | ||
e5ecd5bc | 62 | Catalyst::Exception::Base->meta->make_immutable; |
63 | ||
3cdcf968 | 64 | package Catalyst::Exception; |
65 | ||
66 | use Moose; | |
67 | use vars qw[$CATALYST_EXCEPTION_CLASS]; | |
68 | ||
69 | BEGIN { | |
70 | extends($CATALYST_EXCEPTION_CLASS || 'Catalyst::Exception::Base'); | |
71 | } | |
72 | ||
6680c772 | 73 | no Moose; |
74 | __PACKAGE__->meta->make_immutable; | |
e5ecd5bc | 75 | |
a2f2cde9 | 76 | 1; |