CC: | wat4dog [...] gmail.com |
Hi!
First - sorry for my english :(
So, about bug which i found:
In my case mysql.sock placed at wrong path (/var/lib/mysql instead of
/var/run/mysql - I've reserched it after few fixes to your module, see
below) and when i've tried to use my Model based on your Catalyst said
me "can't call method "do" on undefined value", so, this is true, cuz
$self->dbh was undef.
Then I've tried to debug this, because Catalyst _debug (actually from
your Catalyst::Model::DBI module) said me "Connected to database XXX via
dsn YYY". And it wasn't true. Because your "connect" method "eval"
DBI->connect and catch $@ as errors, but if $@ is empty, then this say
"connected". So, DBI->connect doesn't throw exceptions, and when i've
added DBI->errstr catching i've got nice result.
Part of code:
sub connect {
my $self = shift;
my $dbh;
eval {
$dbh = DBI->connect(
$self->{dsn},
$self->{username} || $self->{user},
$self->{password} || $self->{pass},
$self->{options}
) || die DBI->errstr; ### plz attention here
};
if ($@) { $self->{log}->debug( qq{Couldn't connect to the
database "$@"} ) if $self->{debug} }
else { $self->{log}->debug ( 'Connected to the database via
dsn:' . $self->{dsn} ) if $self->{debug}; }
$self->_pid( $$ );
$self->_tid( threads->tid ) if $INC{'threads.pm'};
return $dbh;
}
As you can see i've added || die DBI->errstr (force exception throwing).
In this case $@ wasn't empty and i've seen ACTUAL error message "Can't
connect to MySQL via socket /var/run/mysql.sock"
I suggest you to add force exception throwing to fill $@ var with
correct error message, to allow users see actual errors/problems :)
Thank you for your attention, and I'm so sorry for my english. I hope
what you'll understand me :)
--
WBR, Anton.