From: Peter Rabbitson Date: Wed, 26 May 2010 10:00:19 +0000 (+0000) Subject: Can not return from within a try block X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dd415de8014e0461d73eb092089b1f51dc894884;p=dbsrgits%2FDBIx-Class-Historic.git Can not return from within a try block --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 76e9c49..0efff67 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -728,8 +728,8 @@ sub dbh_do { local $self->{_in_dbh_do} = 1; my @args = @_; - try { - return $self->$code ($dbh, @args); + return try { + $self->$code ($dbh, @args); } catch { $self->throw_exception($_) if $self->connected; diff --git a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm index f3b178e..9e72eae 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm @@ -125,11 +125,22 @@ sub _dbh_execute { my $self = shift; my ($dbh, $op, $extra_bind, $ident, $bind_attributes, @args) = @_; - my $retried; + my (@res, $retried); + my $wantarray = wantarray(); my $next = $self->next::can; while (1) { try { - return $self->$next($dbh, $op, $extra_bind, $ident, $bind_attributes, @args); + my $exec = sub { $self->$next($dbh, $op, $extra_bind, $ident, $bind_attributes, @args) }; + + if (!defined $wantarray) { + $exec->(); + } + elsif (! $wantarray) { + $res[0] = $exec->(); + } + else { + @res = $exec->(); + } } catch { if (!$retried++ and $_ =~ /ORA-01003/) { @@ -143,6 +154,8 @@ sub _dbh_execute { } }; } + + return $wantarray ? @res : $res[0]; } =head2 get_autoinc_seq