X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage.pm;h=d949b01e428c06969605405909e242d3ac0d0686;hb=e5053694;hp=fc87ceb05c2dfa7d6ec2d61e6a1b6056b398b3b0;hpb=0dd1b7362ff4b104d68946ae6ca8e7e483621381;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage.pm b/lib/DBIx/Class/Storage.pm index fc87ceb..d949b01 100644 --- a/lib/DBIx/Class/Storage.pm +++ b/lib/DBIx/Class/Storage.pm @@ -16,6 +16,7 @@ use DBIx::Class::Carp; use DBIx::Class::Storage::BlockRunner; use Scalar::Util qw/blessed weaken/; use DBIx::Class::Storage::TxnScopeGuard; +use DBIx::Class::_Util qw( dbic_internal_try fail_on_internal_call ); use Try::Tiny; use namespace::clean; @@ -24,7 +25,10 @@ __PACKAGE__->mk_group_accessors(component_class => 'cursor_class'); __PACKAGE__->cursor_class('DBIx::Class::Cursor'); -sub cursor { shift->cursor_class(@_); } +sub cursor { + DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call; + shift->cursor_class(@_); +} =head1 NAME @@ -253,12 +257,12 @@ sub txn_rollback { $self->{transaction_depth}--; # in case things get really hairy - just disconnect - eval { $self->_exec_txn_rollback; 1 } or do { + dbic_internal_try { $self->_exec_txn_rollback; 1 } or do { my $rollback_error = $@; # whatever happens, too low down the stack to care # FIXME - revisit if stackable exceptions become a thing - eval { $self->disconnect }; + dbic_internal_try { $self->disconnect }; die $rollback_error; }; @@ -310,16 +314,19 @@ sub __delicate_rollback { return; } + my @args = @_; my $rbe; - local $@; # taking no chances - unless( eval { $self->txn_rollback; 1 } ) { + dbic_internal_try { + $self->txn_rollback; 1 + } + catch { - $rbe = $@; + $rbe = $_; # we were passed an existing exception to augment (think DESTROY stacks etc) - if (@_) { - my $exception = shift; + if (@args) { + my ($exception) = @args; # append our text - THIS IS A TEMPORARY FIXUP! # @@ -367,7 +374,7 @@ sub __delicate_rollback { ) =~ s/Transaction aborted: (?=Transaction aborted:)//; } } - } + }; return $rbe; } @@ -427,12 +434,15 @@ sub svp_release { if (defined $name) { my @stack = @{ $self->savepoints }; - my $svp; + my $svp = ''; - do { $svp = pop @stack } until $svp eq $name; + while( $svp ne $name ) { - $self->throw_exception ("Savepoint '$name' does not exist") - unless $svp; + $self->throw_exception ("Savepoint '$name' does not exist") + unless @stack; + + $svp = pop @stack; + } $self->savepoints(\@stack); # put back what's left } @@ -573,11 +583,12 @@ sub debugobj { if ($profile =~ /^\.?\//) { + require DBIx::Class::Optional::Dependencies; if ( my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('config_file_reader') ) { $self->throw_exception("Unable to parse TRACE_PROFILE config file '$profile' without $missing"); } - my $cfg = try { + my $cfg = dbic_internal_try { Config::Any->load_files({ files => [$profile], use_ext => 1 }); } catch { # sanitize the error message a bit @@ -603,7 +614,7 @@ sub debugobj { # # Yes I am aware this is fragile and TxnScopeGuard needs # a better fix. This is another yak to shave... :( - try { + dbic_internal_try { DBIx::Class::Storage::Debug::PrettyPrint->new(@pp_args); } catch { $self->throw_exception($_);