bigpresh / Dancer-Plugin-Database

Dancer::Plugin::Database - easy database support for Dancer applications
http://search.cpan.org/dist/Dancer-Plugin-Database
37 stars 36 forks source link

Refusing clobbering of {HandleError} installed on externally supplied DBI handle #57

Open onelesd opened 9 years ago

onelesd commented 9 years ago

Not sure which module to blame here. But the error goes away by commenting this section of Dancer::Plugin::Database::Core.pm

    # To support the database_error hook, use DBI's HandleError option
    #$settings->{dbi_params}{HandleError} = sub {
    #    my ($error, $handle) = @_;
    #    $hook_exec->('database_error', $error, $handle);
    #};

[20564] error @0.028260> [hit #1]request to GET /login crashed: DBIx::Class::Storage::DBI::catch {...} (): DBI Connection failed: DBIx::Class::Storage::DBI::try {...} (): Refusing clobbering of {HandleError} installed on externally supplied DBI handle Dancer::Plugin::Database::Core::Handle=HASH(0x9101c68). Either remove the handler or use the 'unsafe' attribute. at /opt/my-app/lib/App.pm line 247 at /opt/my-app/lib/App.pm line 247 in /usr/local/share/perl/5.14.2/Dancer/Handler.pm l. 101

bigpresh commented 9 years ago

Sorry for the slow response - looks like both Dancer::Plugin::Database and something else in your app are setting HandleError.

Maybe Dancer::Plugin::Database should provide an option to disable the error hook handler if you don't need it?

joshrabinowitz commented 6 years ago

@bigpresh This just hit me when using DBIx::Class on an existing dbh inside Dancer - I worked around by creating a second dbh connection (which I'm not enamored with, because I don't like doubling my database connections). Going to look into submitting a patch to provide an option to disable the error hook handler. Please let me know if you have input

KES777 commented 5 years ago

I get same error. I do not use two connections. I even do not know which module may take precedence to setting up handler second time.

*** cross link