Browse Source

Display exact PDO error on default homepage

ADmad 13 years ago
parent
commit
d6c2df7b6b
2 changed files with 16 additions and 2 deletions
  1. 8 1
      app/View/Pages/home.ctp
  2. 8 1
      lib/Cake/Console/Templates/skel/View/Pages/home.ctp

+ 8 - 1
app/View/Pages/home.ctp

@@ -99,6 +99,13 @@ if (isset($filePresent)):
 		$connected = ConnectionManager::getDataSource('default');
 	} catch (Exception $connectionError) {
 		$connected = false;
+		$errorMsg = $connectionError->getMessage();
+		if (method_exists($connectionError, 'getAttributes')) {
+			$attributes = $connectionError->getAttributes();
+			if (isset($errorMsg['message'])) {
+				$errorMsg .= '<br />' . $attributes['message'];
+			}
+		}
 	}
 ?>
 <p>
@@ -111,7 +118,7 @@ if (isset($filePresent)):
 			echo '<span class="notice">';
 				echo __d('cake_dev', 'Cake is NOT able to connect to the database.');
 				echo '<br /><br />';
-				echo $connectionError->getMessage();
+				echo $errorMsg;
 			echo '</span>';
 		endif;
 	?>

+ 8 - 1
lib/Cake/Console/Templates/skel/View/Pages/home.ctp

@@ -99,6 +99,13 @@ if (isset($filePresent)):
 		$connected = ConnectionManager::getDataSource('default');
 	} catch (Exception $connectionError) {
 		$connected = false;
+		$errorMsg = $connectionError->getMessage();
+		if (method_exists($connectionError, 'getAttributes')) {
+			$attributes = $connectionError->getAttributes();
+			if (isset($errorMsg['message'])) {
+				$errorMsg .= '<br />' . $attributes['message'];
+			}
+		}
 	}
 ?>
 <p>
@@ -111,7 +118,7 @@ if (isset($filePresent)):
 			echo '<span class="notice">';
 				echo __d('cake_dev', 'Cake is NOT able to connect to the database.');
 				echo '<br /><br />';
-				echo $connectionError->getMessage();
+				echo $errorMsg;
 			echo '</span>';
 		endif;
 	?>