Commit | Line | Data |
a2f2cde9 |
1 | package Catalyst::Exception; |
2 | |
a2f2cde9 |
3 | use strict; |
4 | use vars qw[@ISA $CATALYST_EXCEPTION_CLASS]; |
ebfde331 |
5 | |
6 | BEGIN { |
7 | push( @ISA, $CATALYST_EXCEPTION_CLASS || 'Catalyst::Exception::Base' ); |
8 | } |
a2f2cde9 |
9 | |
10 | package Catalyst::Exception::Base; |
11 | |
12 | use strict; |
13 | use Carp (); |
14 | |
15 | =head1 NAME |
16 | |
17 | Catalyst::Exception - Catalyst Exception Class |
18 | |
19 | =head1 SYNOPSIS |
20 | |
21 | Catalyst::Exception->throw( qq/Fatal exception/ ); |
22 | |
23 | See also L<Catalyst>. |
24 | |
25 | =head1 DESCRIPTION |
26 | |
27 | This is the Catalyst Exception class. |
28 | |
29 | =head1 METHODS |
30 | |
b5ecfcf0 |
31 | =head2 throw( $message ) |
a2f2cde9 |
32 | |
b5ecfcf0 |
33 | =head2 throw( message => $message ) |
ebfde331 |
34 | |
b5ecfcf0 |
35 | =head2 throw( error => $error ) |
a2f2cde9 |
36 | |
37 | Throws a fatal exception. |
38 | |
39 | =cut |
40 | |
41 | sub throw { |
42 | my $class = shift; |
43 | my %params = @_ == 1 ? ( error => $_[0] ) : @_; |
44 | |
45 | my $message = $params{message} || $params{error} || $! || ''; |
46 | |
47 | local $Carp::CarpLevel = 1; |
48 | |
49 | Carp::croak($message); |
50 | } |
51 | |
a2f2cde9 |
52 | =head1 AUTHOR |
53 | |
54 | Sebastian Riedel, C<sri@cpan.org> |
55 | Christian Hansen, C<ch@ngmedia.com> |
56 | |
57 | =head1 COPYRIGHT |
58 | |
59 | This program is free software, you can redistribute it and/or modify |
60 | it under the same terms as Perl itself. |
61 | |
62 | =cut |
63 | |
64 | 1; |