Browse Source

Move console related exceptions to Console/Error

ADmad 12 years ago
parent
commit
98c861a686

+ 1 - 3
src/Console/ConsoleInputArgument.php

@@ -16,8 +16,6 @@
  */
 namespace Cake\Console;
 
-use Cake\Error;
-
 /**
  * An object to represent a single argument used in the command line.
  * ConsoleOptionParser creates these when you use addArgument()
@@ -136,7 +134,7 @@ class ConsoleInputArgument {
  *
  * @param string $value
  * @return boolean
- * @throws \Cake\Error\ConsoleException
+ * @throws \Cake\Console\Error\ConsoleException
  */
 	public function validChoice($value) {
 		if (empty($this->_choices)) {

+ 2 - 4
src/Console/ConsoleInputOption.php

@@ -16,8 +16,6 @@
  */
 namespace Cake\Console;
 
-use Cake\Error;
-
 /**
  * An object to represent a single option used in the command line.
  * ConsoleOptionParser creates these when you use addOption()
@@ -77,7 +75,7 @@ class ConsoleInputOption {
  * @param boolean $boolean Whether this option is a boolean option. Boolean options don't consume extra tokens
  * @param string $default The default value for this option.
  * @param array $choices Valid choices for this option.
- * @throws \Cake\Error\ConsoleException
+ * @throws \Cake\Console\Error\ConsoleException
  */
 	public function __construct($name, $short = null, $help = '', $boolean = false, $default = '', $choices = []) {
 		if (is_array($name) && isset($name['name'])) {
@@ -181,7 +179,7 @@ class ConsoleInputOption {
  *
  * @param string $value
  * @return boolean
- * @throws \Cake\Error\ConsoleException
+ * @throws \Cake\Console\Error\ConsoleException
  */
 	public function validChoice($value) {
 		if (empty($this->_choices)) {

+ 4 - 5
src/Console/ConsoleOptionParser.php

@@ -16,7 +16,6 @@
  */
 namespace Cake\Console;
 
-use Cake\Error;
 use Cake\Utility\Inflector;
 
 /**
@@ -464,7 +463,7 @@ class ConsoleOptionParser {
  * @param string $command The subcommand to use. If this parameter is a subcommand, that has a parser,
  *    That parser will be used to parse $argv instead.
  * @return Array [$params, $args]
- * @throws \Cake\Error\ConsoleException When an invalid parameter is encountered.
+ * @throws \Cake\Console\Error\ConsoleException When an invalid parameter is encountered.
  */
 	public function parse($argv, $command = null) {
 		if (isset($this->_subcommands[$command]) && $this->_subcommands[$command]->parser()) {
@@ -556,7 +555,7 @@ class ConsoleOptionParser {
  * @param string $option The option to parse.
  * @param array $params The params to append the parsed value into
  * @return array Params with $option added in.
- * @throws \Cake\Error\ConsoleException When unknown short options are encountered.
+ * @throws \Cake\Console\Error\ConsoleException When unknown short options are encountered.
  */
 	protected function _parseShortOption($option, $params) {
 		$key = substr($option, 1);
@@ -580,7 +579,7 @@ class ConsoleOptionParser {
  * @param string $name The name to parse.
  * @param array $params The params to append the parsed value into
  * @return array Params with $option added in.
- * @throws \Cake\Error\ConsoleException
+ * @throws \Cake\Console\Error\ConsoleException
  */
 	protected function _parseOption($name, $params) {
 		if (!isset($this->_options[$name])) {
@@ -627,7 +626,7 @@ class ConsoleOptionParser {
  * @param string $argument The argument to append
  * @param array $args The array of parsed args to append to.
  * @return array Args
- * @throws \Cake\Error\ConsoleException
+ * @throws \Cake\Console\Error\ConsoleException
  */
 	protected function _parseArg($argument, $args) {
 		if (empty($this->_args)) {

+ 3 - 1
src/Error/ConsoleException.php

@@ -15,7 +15,9 @@
  * @since         3.0.0
  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  */
-namespace Cake\Error;
+namespace Cake\Console\Error;
+
+use Cake\Error\Exception;
 
 /**
  * Exception class for Console libraries.  This exception will be thrown from Console library

+ 3 - 1
src/Error/MissingShellException.php

@@ -15,7 +15,9 @@
  * @since         3.0.0
  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  */
-namespace Cake\Error;
+namespace Cake\Console\Error;
+
+use Cake\Error\Exception;
 
 /**
  * Used when a shell cannot be found.

+ 3 - 1
src/Error/MissingShellMethodException.php

@@ -15,7 +15,9 @@
  * @since         3.0.0
  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  */
-namespace Cake\Error;
+namespace Cake\Console\Error;
+
+use Cake\Error\Exception;
 
 /**
  * Used when a shell method cannot be found.

+ 3 - 1
src/Error/MissingTaskException.php

@@ -15,7 +15,9 @@
  * @since         3.0.0
  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  */
-namespace Cake\Error;
+namespace Cake\Console\Error;
+
+use Cake\Error\Exception;
 
 /**
  * Used when a Task cannot be found.

+ 0 - 1
src/Console/Shell.php

@@ -19,7 +19,6 @@ use Cake\Core\App;
 use Cake\Core\Configure;
 use Cake\Core\Object;
 use Cake\Core\Plugin;
-use Cake\Error;
 use Cake\Utility\ConventionsTrait;
 use Cake\Utility\File;
 use Cake\Utility\Inflector;

+ 5 - 5
src/Console/ShellDispatcher.php

@@ -18,7 +18,7 @@ namespace Cake\Console;
 
 use Cake\Core\App;
 use Cake\Core\Configure;
-use Cake\Error;
+use Cake\Error\Exception;
 use Cake\Utility\Inflector;
 
 /**
@@ -92,7 +92,7 @@ class ShellDispatcher {
 	protected function _initEnvironment() {
 		if (!$this->_bootstrap()) {
 			$message = "Unable to load CakePHP core.\nMake sure " . DS . 'lib' . DS . 'Cake exists in ' . CAKE_CORE_INCLUDE_PATH;
-			throw new Error\Exception($message);
+			throw new Exception($message);
 		}
 
 		if (!isset($this->args[0]) || !isset($this->params['working'])) {
@@ -100,7 +100,7 @@ class ShellDispatcher {
 				"Please make sure that " . DS . 'lib' . DS . 'Cake' . DS . "Console is in your system path,\n" .
 				"and check the cookbook for the correct usage of this command.\n" .
 				"(http://book.cakephp.org/)";
-			throw new Error\Exception($message);
+			throw new Exception($message);
 		}
 
 		$this->shiftArgs();
@@ -132,7 +132,7 @@ class ShellDispatcher {
  * Dispatch a request.
  *
  * @return boolean
- * @throws \Cake\Error\MissingShellMethodException
+ * @throws \Cake\Console\Error\MissingShellMethodException
  */
 	protected function _dispatch() {
 		$shell = $this->shiftArgs();
@@ -184,7 +184,7 @@ class ShellDispatcher {
  *
  * @param string $shell Optionally the name of a plugin
  * @return mixed An object
- * @throws \Cake\Error\MissingShellException when errors are encountered.
+ * @throws \Cake\Console\Error\MissingShellException when errors are encountered.
  */
 	protected function _getShell($shell) {
 		list($plugin, $shell) = pluginSplit($shell);

+ 1 - 2
src/Console/TaskRegistry.php

@@ -15,7 +15,6 @@
 namespace Cake\Console;
 
 use Cake\Core\App;
-use Cake\Error;
 use Cake\Utility\ObjectRegistry;
 
 /**
@@ -59,7 +58,7 @@ class TaskRegistry extends ObjectRegistry {
  *
  * @param string $class The classname that is missing.
  * @param string $plugin The plugin the task is missing in.
- * @throws \Cake\Error\MissingTaskException
+ * @throws \Cake\Console\Error\MissingTaskException
  */
 	protected function _throwMissingClassError($class, $plugin) {
 		throw new Error\MissingTaskException([

+ 7 - 7
tests/TestCase/Console/ConsoleOptionParserTest.php

@@ -174,7 +174,7 @@ class ConsoleOptionParserTest extends TestCase {
  * Test that adding an option using a two letter short value causes an exception.
  * As they will not parse correctly.
  *
- * @expectedException \Cake\Error\ConsoleException
+ * @expectedException \Cake\Console\Error\ConsoleException
  * @return void
  */
 	public function testAddOptionShortOneLetter() {
@@ -272,7 +272,7 @@ class ConsoleOptionParserTest extends TestCase {
 /**
  * test parsing options that do not exist.
  *
- * @expectedException \Cake\Error\ConsoleException
+ * @expectedException \Cake\Console\Error\ConsoleException
  * @return void
  */
 	public function testOptionThatDoesNotExist() {
@@ -285,7 +285,7 @@ class ConsoleOptionParserTest extends TestCase {
 /**
  * test parsing short options that do not exist.
  *
- * @expectedException \Cake\Error\ConsoleException
+ * @expectedException \Cake\Console\Error\ConsoleException
  * @return void
  */
 	public function testShortOptionThatDoesNotExist() {
@@ -298,7 +298,7 @@ class ConsoleOptionParserTest extends TestCase {
 /**
  * test that options with choices enforce them.
  *
- * @expectedException \Cake\Error\ConsoleException
+ * @expectedException \Cake\Console\Error\ConsoleException
  * @return void
  */
 	public function testOptionWithChoices() {
@@ -387,7 +387,7 @@ class ConsoleOptionParserTest extends TestCase {
 /**
  * test parsing arguments.
  *
- * @expectedException \Cake\Error\ConsoleException
+ * @expectedException \Cake\Console\Error\ConsoleException
  * @return void
  */
 	public function testParseArgumentTooMany() {
@@ -418,7 +418,7 @@ class ConsoleOptionParserTest extends TestCase {
 /**
  * test that when there are not enough arguments an exception is raised
  *
- * @expectedException \Cake\Error\ConsoleException
+ * @expectedException \Cake\Console\Error\ConsoleException
  * @return void
  */
 	public function testPositionalArgNotEnough() {
@@ -432,7 +432,7 @@ class ConsoleOptionParserTest extends TestCase {
 /**
  * test that arguments with choices enforce them.
  *
- * @expectedException \Cake\Error\ConsoleException
+ * @expectedException \Cake\Console\Error\ConsoleException
  * @return void
  */
 	public function testPositionalArgWithChoices() {

+ 1 - 1
tests/TestCase/Console/TaskRegistryTest.php

@@ -63,7 +63,7 @@ class TaskRegistryTest extends TestCase {
 /**
  * test missingtask exception
  *
- * @expectedException \Cake\Error\MissingTaskException
+ * @expectedException \Cake\Console\Error\MissingTaskException
  * @return void
  */
 	public function testLoadMissingTask() {