enabling immutable finishing porting Log and stats
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Exception.pm
CommitLineData
a2f2cde9 1package Catalyst::Exception;
2
3cdcf968 3# XXX: See bottom of file for Exception implementation
a2f2cde9 4
5package Catalyst::Exception::Base;
6
3cdcf968 7use Moose;
a2f2cde9 8use Carp ();
9
10=head1 NAME
11
12Catalyst::Exception - Catalyst Exception Class
13
14=head1 SYNOPSIS
15
16 Catalyst::Exception->throw( qq/Fatal exception/ );
17
18See also L<Catalyst>.
19
20=head1 DESCRIPTION
21
22This 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
32Throws a fatal exception.
33
34=cut
35
36sub 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
49Provided by Moose
50
a2f2cde9 51=head1 AUTHOR
52
53Sebastian Riedel, C<sri@cpan.org>
54Christian Hansen, C<ch@ngmedia.com>
55
56=head1 COPYRIGHT
57
58This program is free software, you can redistribute it and/or modify
59it under the same terms as Perl itself.
60
61=cut
62
e5ecd5bc 63Catalyst::Exception::Base->meta->make_immutable;
64
3cdcf968 65package Catalyst::Exception;
66
67use Moose;
68use vars qw[$CATALYST_EXCEPTION_CLASS];
69
70BEGIN {
71 extends($CATALYST_EXCEPTION_CLASS || 'Catalyst::Exception::Base');
72}
73
e5ecd5bc 74Catalyst::Exception->meta->make_immutable;
75
a2f2cde9 761;