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;
use lib qw(t/lib);
use DBICTest;
-plan tests => 8;
+plan tests => 9;
# Set up the "usual" sqlite for DBICTest
my $schema = DBICTest->init_schema;
# While we're at it, lets throw a custom exception through Storage::DBI
eval { $schema->storage->throw_exception('floob') };
like($@, qr/DBICTest::Exception is handling this: floob/);
+
+
+# This usage is a bit unusual but it was actually seen in the wild
+eval {
+
+ my $dbh = $schema->storage->dbh;
+ undef $schema;
+
+ $dbh->do ('glaring_syntax_error;');
+};
+like($@, qr/DBI Exception.+do failed/, 'Exception thrown even after $storage is destroyed');
+