1 package DBIx::Class::Exception;
6 use DBIx::Class::Carp ();
7 $Carp::Internal{ (__PACKAGE__) }++;
10 '""' => sub { shift->{msg} },
15 DBIx::Class::Exception - Exception objects for DBIx::Class
19 Exception objects of this class are used internally by
20 the default error handling of L<DBIx::Class::Schema/throw_exception>
23 These objects stringify to the contained error message, and use
24 overload fallback to give natural boolean/numeric values.
32 =item Arguments: $exception_scalar, $stacktrace
36 This is meant for internal use by L<DBIx::Class>'s C<throw_exception>
37 code, and shouldn't be used directly elsewhere.
39 Expects a scalar exception message. The optional argument
40 C<$stacktrace> tells it to output a full trace similar to L<Carp/confess>.
42 DBIx::Class::Exception->throw('Foo');
43 try { ... } catch { DBIx::Class::Exception->throw(shift) }
48 my ($class, $msg, $stacktrace) = @_;
50 # Don't re-encapsulate exception objects of any kind
51 die $msg if ref($msg);
53 # all exceptions include a caller
57 # skip all frames that match the original caller, or any of
58 # the dbic-wide classdata patterns
59 my ($ln, $calling) = DBIx::Class::Carp::__find_caller(
64 $msg = "${calling}${msg} ${ln}\n";
67 $msg = Carp::longmess($msg);
70 my $self = { msg => $msg };
71 bless $self => $class;
78 This method provides some syntactic sugar in order to
87 =head1 AUTHOR AND CONTRIBUTORS
89 See L<AUTHOR|DBIx::Class/AUTHOR> and L<CONTRIBUTORS|DBIx::Class/CONTRIBUTORS> in DBIx::Class
93 You may distribute this code under the same terms as Perl itself.