Try::Tiny conversion finished
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Schema / Versioned.pm
index a10e1fd..8aa9b6a 100644 (file)
@@ -182,6 +182,7 @@ use base 'DBIx::Class::Schema';
 
 use Carp::Clan qw/^DBIx::Class/;
 use Time::HiRes qw/gettimeofday/;
+use Try::Tiny;
 
 __PACKAGE__->mk_classdata('_filedata');
 __PACKAGE__->mk_classdata('upgrade_directory');
@@ -503,9 +504,8 @@ sub get_db_version
     my ($self, $rs) = @_;
 
     my $vtable = $self->{vschema}->resultset('Table');
-    my $version;
-    try {
-      $version = $vtable->search({}, { order_by => { -desc => 'installed' }, rows => 1 } )
+    my $version = try {
+      $vtable->search({}, { order_by => { -desc => 'installed' }, rows => 1 } )
               ->get_column ('version')
                ->next;
     };
@@ -725,16 +725,9 @@ sub _source_exists
 {
     my ($self, $rs) = @_;
 
-    my $c;
-    my $exception;
-    try {
-        $c = $rs->search({ 1, 0 })->count;
-    } catch {
-        $exception=1;
-    };
-    return 0 if $exception || !defined $c;
+    my $c = try { $rs->search({ 1, 0 })->count };
 
-    return 1;
+    return (defined $c) ? 1 : 0;
 }
 
 1;