From: Peter Rabbitson Date: Mon, 31 Jan 2011 16:00:46 +0000 (+0100) Subject: Better exception when things get really really bad with prepare() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e1a97e2459751c5151128c30900749c7143bc650;p=dbsrgits%2FDBIx-Class-Historic.git Better exception when things get really really bad with prepare() --- diff --git a/Changes b/Changes index a1d6ac5..ddeda06 100644 --- a/Changes +++ b/Changes @@ -11,6 +11,7 @@ Revision history for DBIx::Class - Fix dropped bind values in select/group_by on Oracle (omission from 0542ec57 and 4c2b30d6) - Fix problems with M.A.D. under CGI::SpeedyCGI (RT#65131) + - Better error handling when prepare() fails silently 0.08127 2011-01-19 16:40 (UTC) * New Features / Changes diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 7d7a8bb..dfa2e1e 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -2280,7 +2280,18 @@ sub _dbh_sth { # XXX You would think RaiseError would make this impossible, # but apparently that's not true :( - $self->throw_exception($dbh->errstr) if !$sth; + $self->throw_exception( + $dbh->errstr + || + sprintf( "\$dbh->prepare() of '%s' through %s failed *silently* without " + .'an exception and/or setting $dbh->errstr', + length ($sql) > 20 + ? substr($sql, 0, 20) . '...' + : $sql + , + 'DBD::' . $dbh->{Driver}{Name}, + ) + ) if !$sth; $sth; }