Browse Source

Remove ConfigureException. Just use Exception intead.

ADmad 12 years ago
parent
commit
b4ad76e628

+ 3 - 3
src/Configure/Engine/IniConfig.php

@@ -94,17 +94,17 @@ class IniConfig implements ConfigEngineInterface {
  * @param string $key The identifier to read from. If the key has a . it will be treated
  *  as a plugin prefix. The chosen file must be on the engine's path.
  * @return array Parsed configuration values.
- * @throws \Cake\Error\ConfigureException when files don't exist.
+ * @throws \Cake\Error\Exception when files don't exist.
  *  Or when files contain '..' as this could lead to abusive reads.
  */
 	public function read($key) {
 		if (strpos($key, '..') !== false) {
-			throw new Error\ConfigureException('Cannot load configuration files with ../ in them.');
+			throw new Error\Exception('Cannot load configuration files with ../ in them.');
 		}
 
 		$file = $this->_getFilePath($key);
 		if (!is_file($file)) {
-			throw new Error\ConfigureException(sprintf('Could not load configuration file: %s', $file));
+			throw new Error\Exception(sprintf('Could not load configuration file: %s', $file));
 		}
 
 		$contents = parse_ini_file($file, true);

+ 4 - 4
src/Configure/Engine/PhpConfig.php

@@ -57,22 +57,22 @@ class PhpConfig implements ConfigEngineInterface {
  * @param string $key The identifier to read from. If the key has a . it will be treated
  *  as a plugin prefix.
  * @return array Parsed configuration values.
- * @throws \Cake\Error\ConfigureException when files don't exist or they don't contain `$config`.
+ * @throws \Cake\Error\Exception when files don't exist or they don't contain `$config`.
  *  Or when files contain '..' as this could lead to abusive reads.
  */
 	public function read($key) {
 		if (strpos($key, '..') !== false) {
-			throw new Error\ConfigureException('Cannot load configuration files with ../ in them.');
+			throw new Error\Exception('Cannot load configuration files with ../ in them.');
 		}
 
 		$file = $this->_getFilePath($key);
 		if (!is_file($file)) {
-			throw new Error\ConfigureException(sprintf('Could not load configuration file: %s', $file));
+			throw new Error\Exception(sprintf('Could not load configuration file: %s', $file));
 		}
 
 		include $file;
 		if (!isset($config)) {
-			throw new Error\ConfigureException(sprintf('No variable $config found in %s', $file));
+			throw new Error\Exception(sprintf('No variable $config found in %s', $file));
 		}
 		return $config;
 	}

+ 3 - 4
src/Core/Configure.php

@@ -235,7 +235,6 @@ class Configure {
  * @param string $config Name of the configured engine to use to read the resource identified by $key.
  * @param boolean $merge if config files should be merged instead of simply overridden
  * @return mixed false if file not found, void if load successful.
- * @throws \Cake\Error\ConfigureException Will throw any exceptions the engine raises.
  */
 	public static function load($key, $config = 'default', $merge = true) {
 		$engine = static::_getEngine($config);
@@ -279,15 +278,15 @@ class Configure {
  * @param array $keys The name of the top-level keys you want to dump.
  *   This allows you save only some data stored in Configure.
  * @return boolean success
- * @throws \Cake\Error\ConfigureException if the adapter does not implement a `dump` method.
+ * @throws \Cake\Error\Exception if the adapter does not implement a `dump` method.
  */
 	public static function dump($key, $config = 'default', $keys = []) {
 		$engine = static::_getEngine($config);
 		if (!$engine) {
-			throw new Error\ConfigureException(sprintf('There is no "%s" config engine.', $config));
+			throw new Error\Exception(sprintf('There is no "%s" config engine.', $config));
 		}
 		if (!method_exists($engine, 'dump')) {
-			throw new Error\ConfigureException(sprintf('The "%s" config engine, does not have a dump() method.', $config));
+			throw new Error\Exception(sprintf('The "%s" config engine, does not have a dump() method.', $config));
 		}
 		$values = static::$_values;
 		if (!empty($keys) && is_array($keys)) {

+ 0 - 26
src/Error/ConfigureException.php

@@ -1,26 +0,0 @@
-<?php
-/**
- * ConfigureException class
- *
- * PHP 5
- *
- * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
- * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
- *
- * Licensed under The MIT License
- * Redistributions of files must retain the above copyright notice.
- *
- * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
- * @link          http://book.cakephp.org/2.0/en/development/testing.html
- * @since         3.0.0
- * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
- */
-namespace Cake\Error;
-
-/**
- * Exception class for Configure.  This exception will be thrown from Configure when it
- * encounters an error.
- *
- */
-class ConfigureException extends Exception {
-}

+ 3 - 3
tests/TestCase/Configure/Engine/IniConfigTest.php

@@ -168,7 +168,7 @@ class IniConfigTest extends TestCase {
 /**
  * Test an exception is thrown by reading files that exist without .ini extension.
  *
- * @expectedException \Cake\Error\ConfigureException
+ * @expectedException \Cake\Error\Exception
  * @return void
  */
 	public function testReadWithExistentFileWithoutExtension() {
@@ -179,7 +179,7 @@ class IniConfigTest extends TestCase {
 /**
  * Test an exception is thrown by reading files that don't exist.
  *
- * @expectedException \Cake\Error\ConfigureException
+ * @expectedException \Cake\Error\Exception
  * @return void
  */
 	public function testReadWithNonExistentFile() {
@@ -201,7 +201,7 @@ class IniConfigTest extends TestCase {
 /**
  * Test reading keys with ../ doesn't work.
  *
- * @expectedException \Cake\Error\ConfigureException
+ * @expectedException \Cake\Error\Exception
  * @return void
  */
 	public function testReadWithDots() {

+ 4 - 4
tests/TestCase/Configure/Engine/PhpConfigTest.php

@@ -75,7 +75,7 @@ class PhpConfigTest extends TestCase {
 /**
  * Test an exception is thrown by reading files that exist without .php extension.
  *
- * @expectedException \Cake\Error\ConfigureException
+ * @expectedException \Cake\Error\Exception
  * @return void
  */
 	public function testReadWithExistentFileWithoutExtension() {
@@ -86,7 +86,7 @@ class PhpConfigTest extends TestCase {
 /**
  * Test an exception is thrown by reading files that don't exist.
  *
- * @expectedException \Cake\Error\ConfigureException
+ * @expectedException \Cake\Error\Exception
  * @return void
  */
 	public function testReadWithNonExistentFile() {
@@ -97,7 +97,7 @@ class PhpConfigTest extends TestCase {
 /**
  * Test reading an empty file.
  *
- * @expectedException \Cake\Error\ConfigureException
+ * @expectedException \Cake\Error\Exception
  * @return void
  */
 	public function testReadEmptyFile() {
@@ -108,7 +108,7 @@ class PhpConfigTest extends TestCase {
 /**
  * Test reading keys with ../ doesn't work.
  *
- * @expectedException \Cake\Error\ConfigureException
+ * @expectedException \Cake\Error\Exception
  * @return void
  */
 	public function testReadWithDots() {

+ 1 - 1
tests/TestCase/Core/ConfigureTest.php

@@ -428,7 +428,7 @@ class ConfigureTest extends TestCase {
 	}
 
 /**
- * @expectedException \Cake\Error\ConfigureException
+ * @expectedException \Cake\Error\Exception
  * @return void
  */
 	public function testDumpNoAdapter() {

+ 0 - 5
tests/TestCase/Error/ExceptionRendererTest.php

@@ -579,11 +579,6 @@ class ExceptionRendererTest extends TestCase {
 				new Error\Exception('base class'),
 				array('/Internal Error/'),
 				500
-			),
-			array(
-				new Error\ConfigureException('No file'),
-				array('/Internal Error/'),
-				500
 			)
 		);
 	}