X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FReplicated%2FPool.pm;h=1a8347d99a5c456c83482f8f5201816774daaca3;hb=f92a9d790b900dcb183ff62b4e2e770a53f01ac6;hp=db38c42680a650c833dbdc15ecb7be1b83585ae2;hpb=48580715af3072905f2c71dc27e7f70f21a11338;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm b/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm index db38c42..1a8347d 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm @@ -8,6 +8,7 @@ use DBI (); use Carp::Clan qw/^DBIx::Class/; use MooseX::Types::Moose qw/Num Int ClassName HashRef/; use DBIx::Class::Storage::DBI::Replicated::Types 'DBICStorageDBI'; +use Try::Tiny; use namespace::clean -except => 'meta'; @@ -293,18 +294,16 @@ Returns 1 on success and undef on failure. sub _safely { my ($self, $replicant, $name, $code) = @_; - eval { - $code->() - }; - if ($@) { + return try { + $code->(); + 1; + } catch { $replicant->debugobj->print(sprintf( "Exception trying to $name for replicant %s, error is %s", - $replicant->_dbi_connect_info->[0], $@) + $replicant->_dbi_connect_info->[0], $_) ); - return undef; - } - - return 1; + undef; + }; } =head2 connected_replicants @@ -364,7 +363,7 @@ This does a check to see if 1) each replicate is connected (or reconnectable), defined by L. Replicants that fail any of these tests are set to inactive, and thus removed from the replication pool. -This tests L, since a replicant that has been previous marked +This tests L, since a replicant that has been previous marked as inactive can be reactivated should it start to pass the validation tests again. See L for more about checking if a replicating