X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FSybase.pm;h=8019569b575ae5928342deec2311dcd17e39848b;hp=8c5f988dcfaf00cf57cc28708a40f6a37cde6076;hb=ed7ab0f4ce1a9118ea6285ee562ef003085a6b64;hpb=7803e57ad8daee28020676140ea6894c31e3112e diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 8c5f988..8019569 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -2,6 +2,7 @@ package DBIx::Class::Storage::DBI::Sybase; use strict; use warnings; +use Try::Tiny; use base qw/DBIx::Class::Storage::DBI/; @@ -22,13 +23,13 @@ L sub _rebless { my $self = shift; - my $dbtype = eval { - @{$self->_get_dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2] + my $dbtype; + try { + $dbtype = @{$self->_get_dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2] + } catch { + $self->throw_exception("Unable to estable connection to determine database type: $_") }; - $self->throw_exception("Unable to estable connection to determine database type: $@") - if $@; - if ($dbtype) { $dbtype =~ s/\W/_/gi; @@ -57,13 +58,16 @@ sub _ping { return $@ ? 0 : $ping; } - eval { + my $rc = 1; + try { # XXX if the main connection goes stale, does opening another for this statement # really determine anything? $dbh->do('select 1'); + } catch { + $rc = 0; }; - return $@ ? 0 : 1; + return $rc; } sub _set_max_connect {