Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Test-Exception CPAN distribution.

Report information
The Basics
Id: 17795
Status: rejected
Priority: 0/
Queue: Test-Exception

People
Owner: Nobody in particular
Requestors: dwheeler [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: timb [...] cpan.org
Subject: Fails to Catch Certain DBI Exceptions
Date: Tue, 21 Feb 2006 22:24:30 -0800
To: bug-test-exception [...] rt.cpan.org
From: "David E. Wheeler" <dwheeler [...] cpan.org>
Some DBI exceptions are not properly caught by Test::Exception. For example, this script: use strict; use Test::More tests => 1; use Test::Exception; use DBI; dies_ok { DBI->connect('dbi:Pg:dbname=ick', 'postgres', '') } 'DBI should die with bogus values'; When I run it, I get: 1..1 DBI connect('dbname=ick','postgres',...) failed: FATAL: database "ick" does not exist at /usr/local/lib/perl5/site_perl/5.8.7/Test/Exception.pm line 128 not ok 1 - DBI should die with bogus values # Failed test 'DBI should die with bogus values' # in /Users/david/bin/try at line 9. # Looks like you failed 1 test of 1. That's not what I expect, of course. The problem doesn't exist for all DBI exceptions, though. If I change the DSN to just 'foo', dies_ok will catch it. But when I have a correct DSN and database username and password, DBD::Pg that generates the exception (using DBI's exception-handling C function, I believe), and then Test::Exception doesn't catch it. This is not local to DBD::Pg. If I change the test to use SQLite: dies_ok { DBI->connect('dbi:SQLite:dbname=/root/foo', '', '') } 'DBI should die with bogus values'; Then I get the same problem: 1..1 DBI connect('dbname=/root/foo','',...) failed: unable to open database file(1) at dbdimp.c line 94 at /usr/local/lib/perl5/ site_perl/5.8.7/Test/Exception.pm line 128 not ok 1 - DBI should die with bogus values # Failed test 'DBI should die with bogus values' # in /Users/david/bin/try at line 10. # Looks like you failed 1 test of 1. I'm Cc'ing Tim on this in case he has some suggestions as to what might be different about exceptions thrown by the DBI. Thanks! David
Subject: Re: [rt.cpan.org #17795] AutoReply: Fails to Catch Certain DBI Exceptions
Date: Tue, 21 Feb 2006 22:39:28 -0800
To: bug-Test-Exception [...] rt.cpan.org
From: "David E. Wheeler" <dwheeler [...] cpan.org>
Bugger! Never mind, it's my fault. If I do this, it works, of course: use strict; use Test::More tests => 1; use Test::Exception; use DBI; dies_ok { DBI->connect( 'dbi:Pg:dbname=ick', 'postgres', '', { RaiseError => 1, PrintError => 0, }, ) } 'DBI should die with bogus values'; Thanks. David
Subject: Re: [rt.cpan.org #17795] AutoReply: Fails to Catch Certain DBI Exceptions
Date: Mon, 27 Feb 2006 10:45:05 +0000
To: bug-Test-Exception [...] rt.cpan.org
From: Adrian Howard <adrianh [...] quietstars.com>
No worries :-) Adrian On 22 Feb 2006, at 06:40, David Wheeler via RT wrote: Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=17795 > > > Bugger! Never mind, it's my fault. If I do this, it works, of course: > > use strict; > use Test::More tests => 1; > use Test::Exception; > use DBI; > > dies_ok { > DBI->connect( > 'dbi:Pg:dbname=ick', 'postgres', '', > { RaiseError => 1, PrintError => 0, }, > ) > } 'DBI should die with bogus values'; > > Thanks. > > David > >