From: Peter Rabbitson Date: Sun, 20 Jan 2013 18:23:48 +0000 (+0100) Subject: Some cleanups around loading/use of DBIx::Class::Exception (no func. changes) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f9080e4502d65c87e9c2486ca6a76b166cf1ca8f;p=dbsrgits%2FDBIx-Class-Historic.git Some cleanups around loading/use of DBIx::Class::Exception (no func. changes) --- diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index 3518d42..15718f6 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -58,6 +58,7 @@ use DBIx::Class::Optional::Dependencies; use base qw/DBIx::Class::Componentised DBIx::Class::AccessorGroup/; use DBIx::Class::StartupCheck; +use DBIx::Class::Exception; __PACKAGE__->mk_group_accessors(inherited => '_skip_namespace_frames'); __PACKAGE__->_skip_namespace_frames('^DBIx::Class|^SQL::Abstract|^Try::Tiny|^Class::Accessor::Grouped|^Context::Preserve'); diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 204b75f..545f993 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -4,7 +4,6 @@ use strict; use warnings; use base qw/DBIx::Class/; use DBIx::Class::Carp; -use DBIx::Class::Exception; use DBIx::Class::ResultSetColumn; use Scalar::Util qw/blessed weaken/; use Try::Tiny; diff --git a/lib/DBIx/Class/ResultSetColumn.pm b/lib/DBIx/Class/ResultSetColumn.pm index f372e9d..92abc07 100644 --- a/lib/DBIx/Class/ResultSetColumn.pm +++ b/lib/DBIx/Class/ResultSetColumn.pm @@ -5,7 +5,6 @@ use warnings; use base 'DBIx::Class'; use DBIx::Class::Carp; -use DBIx::Class::Exception; # not importing first() as it will clash with our own method use List::Util (); @@ -438,7 +437,7 @@ See L for details. =cut sub throw_exception { - my $self=shift; + my $self = shift; if (ref $self && $self->{_parent_resultset}) { $self->{_parent_resultset}->throw_exception(@_); diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 7dfb688..2874611 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -6,7 +6,6 @@ use warnings; use DBIx::Class::ResultSet; use DBIx::Class::ResultSourceHandle; -use DBIx::Class::Exception; use DBIx::Class::Carp; use Devel::GlobalDestruction; use Try::Tiny; diff --git a/lib/DBIx/Class/ResultSourceHandle.pm b/lib/DBIx/Class/ResultSourceHandle.pm index e0dbd08..733db83 100644 --- a/lib/DBIx/Class/ResultSourceHandle.pm +++ b/lib/DBIx/Class/ResultSourceHandle.pm @@ -5,9 +5,7 @@ use warnings; use base qw/DBIx::Class/; -use DBIx::Class::Exception; use Try::Tiny; - use namespace::clean; use overload diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index 4c83edc..4c7110f 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -5,7 +5,6 @@ use warnings; use base qw/DBIx::Class/; -use DBIx::Class::Exception; use Scalar::Util 'blessed'; use List::Util 'first'; use Try::Tiny; diff --git a/lib/DBIx/Class/SQLMaker.pm b/lib/DBIx/Class/SQLMaker.pm index c5b0888..1162280 100644 --- a/lib/DBIx/Class/SQLMaker.pm +++ b/lib/DBIx/Class/SQLMaker.pm @@ -40,7 +40,6 @@ use mro 'c3'; use Sub::Name 'subname'; use DBIx::Class::Carp; -use DBIx::Class::Exception; use namespace::clean; __PACKAGE__->mk_group_accessors (simple => qw/quote_char name_sep limit_dialect/); diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 6fca48e..3bf644a 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -3,7 +3,6 @@ package DBIx::Class::Schema; use strict; use warnings; -use DBIx::Class::Exception; use DBIx::Class::Carp; use Try::Tiny; use Scalar::Util qw/weaken blessed/; @@ -1058,7 +1057,6 @@ default behavior will provide a detailed stack trace. =cut -my $false_exception_action_warned; sub throw_exception { my $self = shift; @@ -1071,13 +1069,12 @@ sub throw_exception { ." (original error: $_[0])" ); } - elsif(! $false_exception_action_warned++) { - carp ( - "The exception_action handler installed on $self returned false instead" - .' of throwing an exception. This behavior has been deprecated, adjust your' - .' handler to always rethrow the supplied error.' - ); - } + + carp_unique ( + "The exception_action handler installed on $self returned false instead" + .' of throwing an exception. This behavior has been deprecated, adjust your' + .' handler to always rethrow the supplied error.' + ); } DBIx::Class::Exception->throw($_[0], $self->stacktrace); diff --git a/lib/DBIx/Class/Storage/BlockRunner.pm b/lib/DBIx/Class/Storage/BlockRunner.pm index 8b9ea26..404e480 100644 --- a/lib/DBIx/Class/Storage/BlockRunner.pm +++ b/lib/DBIx/Class/Storage/BlockRunner.pm @@ -76,7 +76,7 @@ has retried_count => ( default => quote_sub(q{ 0 }), lazy => 1, trigger => quote_sub(q{ - DBIx::Class::Exception->throw(sprintf ( + $_[0]->throw_exception( sprintf ( 'Exceeded max_retried_count amount of %d, latest exception: %s', $_[0]->max_retried_count, $_[0]->last_exception )) if $_[0]->max_retried_count < ($_[1]||0); @@ -93,10 +93,12 @@ has exception_stack => ( sub last_exception { shift->exception_stack->[-1] } +sub throw_exception { shift->storage->throw_exception (@_) } + sub run { my $self = shift; - DBIx::Class::Exception->throw('run() takes no arguments') if @_; + $self->throw_exception('run() takes no arguments') if @_; $self->_reset_exception_stack; $self->_reset_retried_count; diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 19bc2bc..4141a15 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -8,7 +8,6 @@ use base qw/DBIx::Class::Storage::DBIHacks DBIx::Class::Storage/; use mro 'c3'; use DBIx::Class::Carp; -use DBIx::Class::Exception; use Scalar::Util qw/refaddr weaken reftype blessed/; use List::Util qw/first/; use Sub::Name 'subname';