1 package DBIx::Class::Exception;
6 use DBIx::Class::Carp ();
9 '""' => sub { shift->{msg} },
14 DBIx::Class::Exception - Exception objects for DBIx::Class
18 Exception objects of this class are used internally by
19 the default error handling of L<DBIx::Class::Schema/throw_exception>
22 These objects stringify to the contained error message, and use
23 overload fallback to give natural boolean/numeric values.
31 =item Arguments: $exception_scalar, $stacktrace
35 This is meant for internal use by L<DBIx::Class>'s C<throw_exception>
36 code, and shouldn't be used directly elsewhere.
38 Expects a scalar exception message. The optional argument
39 C<$stacktrace> tells it to output a full trace similar to L<Carp/confess>.
41 DBIx::Class::Exception->throw('Foo');
42 try { ... } catch { DBIx::Class::Exception->throw(shift) }
47 my ($class, $msg, $stacktrace) = @_;
49 # Don't re-encapsulate exception objects of any kind
50 die $msg if ref($msg);
52 # all exceptions include a caller
56 # skip all frames that match the original caller, or any of
57 # the dbic-wide classdata patterns
58 my ($ln, $calling) = DBIx::Class::Carp::__find_caller(
63 $msg = "${calling}${msg} ${ln}\n";
66 $msg = Carp::longmess($msg);
69 my $self = { msg => $msg };
70 bless $self => $class;
77 This method provides some syntactic sugar in order to
88 Brandon L. Black <blblack@gmail.com>
92 You may distribute this code under the same terms as Perl itself.