Skip to content

Commit

Permalink
Clean up ShellDispatcher.
Browse files Browse the repository at this point in the history
It no longer needs to work around consoleHandler being undefined. If
people are negligent and remove the error handling in the app/config
then they should be left to their own devices.
  • Loading branch information
markstory committed Aug 20, 2013
1 parent 0889ae5 commit 0bf1040
Showing 1 changed file with 2 additions and 37 deletions.
39 changes: 2 additions & 37 deletions lib/Cake/Console/ShellDispatcher.php
Expand Up @@ -112,56 +112,21 @@ protected function _initEnvironment() {
* @return boolean Success.
*/
protected function _bootstrap() {
$this->setErrorHandlers();

if (!Configure::read('App.fullBaseUrl')) {
Configure::write('App.fullBaseUrl', 'http://localhost');
}

return true;
}

/**
* Set the error/exception handlers for the console
*
* @return void
*/
public function setErrorHandlers() {
$error = Configure::read('Error');
$exception = Configure::read('Exception');

$errorHandler = new ConsoleErrorHandler();
if (empty($error['consoleHandler'])) {
$error['consoleHandler'] = array($errorHandler, 'handleError');
Configure::write('Error', $error);
}
if (empty($exception['consoleHandler'])) {
$exception['consoleHandler'] = array($errorHandler, 'handleException');
Configure::write('Exception', $exception);
}
set_error_handler($error['consoleHandler'], Configure::read('Error.level'));
}

/**
* Dispatches a CLI request
*
* @return integer The cli command exit code. 0 is success.
*/
public function dispatch() {
try {
$exit = 0;
$this->_dispatch();
} catch (\Exception $e) {
$handler = Configure::read('Exception.consoleHandler');
if (is_callable($handler)) {
$exit = call_user_func($handler, $e);
} else {
echo __d('cake_console', "An exception occured\n");
echo __d('cake_console', "But the configured Exception.consoleHandler is not callable\n");
echo $e->getMessage() . "\n";
echo $e->getTraceAsString() . "\n";
}
}
$exit = 0;
$this->_dispatch();
return $exit;
}

Expand Down

0 comments on commit 0bf1040

Please sign in to comment.