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