X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F34exception_action.t;h=173e43586916c03c0d19e6b4b55db0508675492e;hb=cea43436e10983c218ded47e1561183096685f9b;hp=dd54be1322ac00a6f4a93de0fc024fb0af2ead1a;hpb=4ffbc1d6d4ea0462ca64dca0a178fbc219db77a0;p=dbsrgits%2FDBIx-Class.git diff --git a/t/34exception_action.t b/t/34exception_action.t index dd54be1..173e435 100644 --- a/t/34exception_action.t +++ b/t/34exception_action.t @@ -5,7 +5,7 @@ use Test::More; use lib qw(t/lib); use DBICTest; -plan tests => 6; +plan tests => 9; # Set up the "usual" sqlite for DBICTest my $schema = DBICTest->init_schema; @@ -19,6 +19,12 @@ my $ex_regex = qr/Odd number of arguments to search/; # Basic check, normal exception eval { throwex }; +my $e = $@; # like() seems to stringify $@ +like($@, $ex_regex); + +# Re-throw the exception with rethrow() +eval { $e->rethrow }; +isa_ok( $@, 'DBIx::Class::Exception' ); like($@, $ex_regex); # Now lets rethrow via exception_action @@ -60,5 +66,17 @@ eval { throwex }; like($@, qr/DBICTest::Exception is handling this: $ex_regex/); # While we're at it, lets throw a custom exception through Storage::DBI -eval { DBICTest->schema->storage->throw_exception('floob') }; +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'); +