From: Peter Rabbitson Date: Thu, 29 Jan 2009 09:08:51 +0000 (+0000) Subject: port r5016: Fix an obscure bug in the DBI exception handler, clobbering the exception... X-Git-Tag: v0.08011~20 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1c7f4ace54aaab429f1df7446a514dab8ba9c9b1;p=dbsrgits%2FDBIx-Class.git port r5016: Fix an obscure bug in the DBI exception handler, clobbering the exception contents when the same is used outside of dbic code --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 874d3a4..b0a4d57 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -6,6 +6,7 @@ use base 'DBIx::Class::Storage'; use strict; use warnings; use DBI; +use Carp; use SQL::Abstract::Limit; use DBIx::Class::Storage::DBI::Cursor; use DBIx::Class::Storage::Statistics; @@ -843,7 +844,12 @@ sub _connect { my $weak_self = $self; weaken($weak_self); $dbh->{HandleError} = sub { - $weak_self->throw_exception("DBI Exception: $_[0]") + if ($weak_self) { + $weak_self->throw_exception("DBI Exception: $_[0]"); + } + else { + croak ("DBI Exception: $_[0]"); + } }; $dbh->{ShowErrorStatement} = 1; $dbh->{RaiseError} = 1;