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 | |
32 | =over 4 |
33 | |
ebfde331 |
34 | =item throw( $message ) |
35 | |
36 | =item throw( message => $message ) |
37 | |
38 | =item throw( error => $error ) |
a2f2cde9 |
39 | |
40 | Throws a fatal exception. |
41 | |
42 | =cut |
43 | |
44 | sub throw { |
45 | my $class = shift; |
46 | my %params = @_ == 1 ? ( error => $_[0] ) : @_; |
47 | |
48 | my $message = $params{message} || $params{error} || $! || ''; |
49 | |
50 | local $Carp::CarpLevel = 1; |
51 | |
52 | Carp::croak($message); |
53 | } |
54 | |
55 | =back |
56 | |
57 | =head1 AUTHOR |
58 | |
59 | Sebastian Riedel, C<sri@cpan.org> |
60 | Christian Hansen, C<ch@ngmedia.com> |
61 | |
62 | =head1 COPYRIGHT |
63 | |
64 | This program is free software, you can redistribute it and/or modify |
65 | it under the same terms as Perl itself. |
66 | |
67 | =cut |
68 | |
69 | 1; |