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