1 package DBIx::Class::Exception;
6 use Carp::Clan qw/^DBIx::Class|^Try::Tiny/;
11 '""' => sub { shift->{msg} },
16 DBIx::Class::Exception - Exception objects for DBIx::Class
20 Exception objects of this class are used internally by
21 the default error handling of L<DBIx::Class::Schema/throw_exception>
22 to prevent confusing and/or redundant re-application of L<Carp>'s
23 stack trace information.
25 These objects stringify to the contained error message, and use
26 overload fallback to give natural boolean/numeric values.
34 =item Arguments: $exception_scalar, $stacktrace
38 This is meant for internal use by L<DBIx::Class>'s C<throw_exception>
39 code, and shouldn't be used directly elsewhere.
41 Expects a scalar exception message. The optional argument
42 C<$stacktrace> tells it to use L<Carp/longmess> instead of
45 DBIx::Class::Exception->throw('Foo');
46 try { ... } catch { DBIx::Class::Exception->throw(shift) }
51 my ($class, $msg, $stacktrace) = @_;
53 # Don't re-encapsulate exception objects of any kind
54 die $msg if ref($msg);
56 # use Carp::Clan's croak if we're not stack tracing
58 try { croak $msg } catch { $msg = shift };
61 $msg = Carp::longmess($msg);
64 my $self = { msg => $msg };
65 bless $self => $class;
72 This method provides some syntactic sugar in order to
83 Brandon L. Black <blblack@gmail.com>
87 You may distribute this code under the same terms as Perl itself.