1 package DBIx::Class::Exception;
6 # load Carp early to prevent tickling of the ::Internal stash being
7 # interpreted as "Carp is already loaded" by some braindead loader
9 $Carp::Internal{ (__PACKAGE__) }++;
11 use DBIx::Class::Carp ();
14 '""' => sub { shift->{msg} },
19 DBIx::Class::Exception - Exception objects for DBIx::Class
23 Exception objects of this class are used internally by
24 the default error handling of L<DBIx::Class::Schema/throw_exception>
27 These objects stringify to the contained error message, and use
28 overload fallback to give natural boolean/numeric values.
36 =item Arguments: $exception_scalar, $stacktrace
40 This is meant for internal use by L<DBIx::Class>'s C<throw_exception>
41 code, and shouldn't be used directly elsewhere.
43 Expects a scalar exception message. The optional boolean C<$stacktrace>
44 causes it to output a full trace similar to L<confess|Carp/DESCRIPTION>.
46 DBIx::Class::Exception->throw('Foo');
47 try { ... } catch { DBIx::Class::Exception->throw(shift) }
52 my ($class, $msg, $stacktrace) = @_;
54 # Don't re-encapsulate exception objects of any kind
55 die $msg if ref($msg);
57 # all exceptions include a caller
61 # skip all frames that match the original caller, or any of
62 # the dbic-wide classdata patterns
63 my ($ln, $calling) = DBIx::Class::Carp::__find_caller(
64 '^' . CORE::caller() . '$',
68 $msg = "${calling}${msg} ${ln}\n";
71 $msg = Carp::longmess($msg);
74 my $self = { msg => $msg };
75 bless $self => $class;
82 This method provides some syntactic sugar in order to
91 =head1 FURTHER QUESTIONS?
93 Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
95 =head1 COPYRIGHT AND LICENSE
97 This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
98 by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
99 redistribute it and/or modify it under the same terms as the
100 L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.