create now on resultset as well
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / Exception.pm
CommitLineData
78bab9ca 1package DBIx::Class::Exception;
2
3use strict;
4use vars qw[@ISA $DBIC_EXCEPTION_CLASS];
5use UNIVERSAL::require;
6
7BEGIN {
8 push( @ISA, $DBIC_EXCEPTION_CLASS || 'DBIx::Class::Exception::Base' );
9}
10
11package DBIx::Class::Exception::Base;
12
13use strict;
14use Carp ();
15
16=head1 NAME
17
18DBIx::Class::Exception - DBIC Exception Class
19
20=head1 SYNOPSIS
21
22 DBIx::Class::Exception->throw( qq/Fatal exception/ );
23
24See also L<DBIx::Class>.
25
26=head1 DESCRIPTION
27
28This is a generic Exception class for DBIx::Class. You can easily
29replace this with any mechanism implementing 'throw' by setting
30$DBix::Class::Exception::DBIC_EXCEPTION_CLASS
31
32=head1 METHODS
33
8091aa91 34=head2 throw( $message )
78bab9ca 35
8091aa91 36=head2 throw( message => $message )
78bab9ca 37
8091aa91 38=head2 throw( error => $error )
78bab9ca 39
40Throws a fatal exception.
41
42=cut
43
44sub throw {
45 my $class = shift;
46 my %params = @_ == 1 ? ( error => $_[0] ) : @_;
47
48 my $message = $params{message} || $params{error} || $! || '';
49
07037f89 50 local $Carp::CarpLevel = (caller(1) eq 'NEXT' ? 2 : 1);
78bab9ca 51
52 Carp::croak($message);
53}
54
78bab9ca 55=head1 AUTHOR
56
57Marcus Ramberg <mramberg@cpan.org>
58
59=head1 THANKS
60
61Thanks to the L<Catalyst> framework, where this module was borrowed
62from.
63
64=head1 COPYRIGHT
65
66This program is free software, you can redistribute it and/or modify
67it under the same terms as Perl itself.
68
69=cut
70
711;