Throwing exception instead notice in loadConfig.

This commit is contained in:
Juan Basso 2011-01-23 20:00:06 -02:00
parent 175e008308
commit 5b8f680d43
2 changed files with 20 additions and 24 deletions

View file

@ -937,15 +937,14 @@ class HtmlHelper extends AppHelper {
$reader = $configFile[1]; $reader = $configFile[1];
} }
} else { } else {
return trigger_error(__('Cannot load the configuration file. Wrong "configFile" configuration.'), E_USER_NOTICE); throw new ConfigureException(__('Cannot load the configuration file. Wrong "configFile" configuration.'));
} }
$readerClass = Inflector::camelize($reader) . 'Reader'; $readerClass = Inflector::camelize($reader) . 'Reader';
if (!App::import('Lib', 'config/' . $readerClass)) { if (!App::import('Lib', 'config/' . $readerClass)) {
return trigger_error(__('Cannot load the configuration file. Unknown reader.'), E_USER_NOTICE); throw new ConfigureException(__('Cannot load the configuration file. Unknown reader.'));
} }
try {
$readerObj = new $readerClass($path); $readerObj = new $readerClass($path);
$configs = $readerObj->read($file); $configs = $readerObj->read($file);
if (isset($configs['tags']) && is_array($configs['tags'])) { if (isset($configs['tags']) && is_array($configs['tags'])) {
@ -963,9 +962,6 @@ class HtmlHelper extends AppHelper {
if (isset($configs['minimizedAttributeFormat'])) { if (isset($configs['minimizedAttributeFormat'])) {
$this->_minimizedAttributeFormat = $configs['minimizedAttributeFormat']; $this->_minimizedAttributeFormat = $configs['minimizedAttributeFormat'];
} }
} catch (Exception $e) {
return trigger_error(__('Cannot load the configuration file. Failed to load the file.'), E_USER_NOTICE);
}
return $configs; return $configs;
} }

View file

@ -1400,11 +1400,11 @@ class HtmlHelperTest extends CakeTestCase {
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$this->assertEqual($this->Html->getAttribute('_minimizedAttributeFormat'), 'format'); $this->assertEqual($this->Html->getAttribute('_minimizedAttributeFormat'), 'format');
$this->expectError(); $this->expectException('ConfigureException');
$result = $this->Html->loadConfig('wrong_file'); $result = $this->Html->loadConfig('wrong_file');
$this->assertFalse($result); $this->assertFalse($result);
$this->expectError(); $this->expectException('ConfigureException');
$result = $this->Html->loadConfig(array('htmlhelper_tags', 'wrong_reader'), $path); $result = $this->Html->loadConfig(array('htmlhelper_tags', 'wrong_reader'), $path);
$this->assertFalse($result); $this->assertFalse($result);
} }