Skip to content
Permalink
Browse files

better error message in MissingConnectionException when driver is not…

… enabled
  • Loading branch information...
ceeram committed Jun 15, 2012
1 parent 55f3cbe commit b913fe530384df8ce1e4472d4d5669f67babbe84
@@ -337,6 +337,12 @@ class MissingConnectionException extends CakeException {
protected $_messageTemplate = 'Database connection "%s" is missing, or could not be created.';
public function __construct($message, $code = 500) {
if (is_array($message)) {
$message += array('enabled' => true);
}
parent::__construct($message, $code);
}
}
/**
@@ -439,7 +445,7 @@ class MissingPluginException extends CakeException {
}
/**
* Exception class for AclComponent and Interface implementations.
* Exception class for AclComponent and Interface implementations.
*
* @package Cake.Error
*/
@@ -237,7 +237,8 @@ public function __construct($config = null, $autoConnect = true) {
$this->fullDebug = Configure::read('debug') > 1;
if (!$this->enabled()) {
throw new MissingConnectionException(array(
'class' => get_class($this)
'class' => get_class($this),
'enabled' => false
));
}
if ($autoConnect) {
@@ -3429,10 +3429,6 @@ public function setDataSource($dataSource = null) {
}
$this->schemaName = $db->getSchemaName();
if (empty($db) || !is_object($db)) {
throw new MissingConnectionException(array('class' => $this->name));
}
}
/**
@@ -559,6 +559,15 @@ public static function testProvider() {
),
500
),
array(
new MissingConnectionException(array('class' => 'Mysql', 'enabled' => false)),
array(
'/<h2>Missing Database Connection<\/h2>/',
'/Mysql requires a database connection/',
'/Mysql driver is NOT enabled/'
),
500
),
array(
new MissingDatasourceConfigException(array('config' => 'default')),
array(
@@ -21,10 +21,12 @@
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
<?php echo __d('cake_dev', '%s requires a database connection', $class); ?>
</p>
<?php if (!$enabled) : ?>
<p class="error">
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
<?php echo __d('cake_dev', 'Confirm you have created the file : %s.', APP_DIR . DS . 'Config' . DS . 'database.php'); ?>
<?php echo __d('cake_dev', '%s driver is NOT enabled', $class); ?>
</p>
<?php endif; ?>
<p class="notice">
<strong><?php echo __d('cake_dev', 'Notice'); ?>: </strong>
<?php echo __d('cake_dev', 'If you want to customize this error message, create %s.', APP_DIR . DS . 'View' . DS . 'Errors' . DS . basename(__FILE__)); ?>

0 comments on commit b913fe5

Please sign in to comment.
You can’t perform that action at this time.