From 68297d948069dc832044ea1e277e4c6e55a99c5e Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Tue, 15 Jul 2008 12:44:43 +1200 Subject: [PATCH] Fix to the Carp handling when we have a fatal cant connect to the database error Signed-off-by: Joshua Ferraro --- C4/Context.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/C4/Context.pm b/C4/Context.pm index 3144d30954..20e5794bcc 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -26,8 +26,15 @@ BEGIN { # "Note that fatalsToBrowser does not work with mod_perl version 2.0 and higher." import CGI::Carp qw(fatalsToBrowser); sub handle_errors { - my $msg = shift; - my $debug_level = C4::Context->preference("DebugLevel"); + my $msg = shift; + my $debug_level; + eval {C4::Context->dbh();}; + if ($@){ + $debug_level = 1; + } + else { + $debug_level = C4::Context->preference("DebugLevel"); + } print q( @@ -626,7 +633,7 @@ sub _new_dbh my $db_passwd = $context->config("pass"); # MJR added or die here, as we can't work without dbh my $dbh= DBI->connect("DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port", - $db_user, $db_passwd) or die $DBI::errstr; + $db_user, $db_passwd) or die $DBI::errstr; if ( $db_driver eq 'mysql' ) { # Koha 3.0 is utf-8, so force utf8 communication between mySQL and koha, whatever the mysql default config. # this is better than modifying my.cnf (and forcing all communications to be in utf8) -- 2.39.2