- Fixes for rt.cpan #17322 and #17331
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Exception.pm
CommitLineData
a2f2cde9 1package Catalyst::Exception;
2
a2f2cde9 3use strict;
4use vars qw[@ISA $CATALYST_EXCEPTION_CLASS];
ebfde331 5use UNIVERSAL::require;
6
7BEGIN {
8 push( @ISA, $CATALYST_EXCEPTION_CLASS || 'Catalyst::Exception::Base' );
9}
a2f2cde9 10
11package Catalyst::Exception::Base;
12
13use strict;
14use Carp ();
15
16=head1 NAME
17
18Catalyst::Exception - Catalyst Exception Class
19
20=head1 SYNOPSIS
21
22 Catalyst::Exception->throw( qq/Fatal exception/ );
23
24See also L<Catalyst>.
25
26=head1 DESCRIPTION
27
28This 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
38Throws a fatal exception.
39
40=cut
41
42sub 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
55Sebastian Riedel, C<sri@cpan.org>
56Christian Hansen, C<ch@ngmedia.com>
57
58=head1 COPYRIGHT
59
60This program is free software, you can redistribute it and/or modify
61it under the same terms as Perl itself.
62
63=cut
64
651;