1 package DBIx::Class::Exception;
6 use Carp::Clan qw/^DBIx::Class/;
7 use Scalar::Util qw/blessed/;
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>
21 to prevent confusing and/or redundant re-application of L<Carp>'s
22 stack trace information.
24 These objects stringify to the contained error message, and use
25 overload fallback to give natural boolean/numeric values.
33 =item Arguments: $exception_scalar, $stacktrace
37 This is meant for internal use by L<DBIx::Class>'s C<throw_exception>
38 code, and shouldn't be used directly elsewhere.
40 Expects a scalar exception message. The optional argument
41 C<$stacktrace> tells it to use L<Carp/longmess> instead of
44 DBIx::Class::Exception->throw('Foo');
45 eval { ... }; DBIx::Class::Exception->throw($@) if $@;
50 my ($class, $msg, $stacktrace) = @_;
52 # Don't re-encapsulate exception objects of any kind
53 die $msg if blessed($msg);
55 # use Carp::Clan's croak if we're not stack tracing
62 $msg = Carp::longmess($msg);
65 my $self = { msg => $msg };
66 bless $self => $class;
73 This method provides some syntactic sugar in order to
84 Brandon L. Black <blblack@gmail.com>
88 You may distribute this code under the same terms as Perl itself.