Skip to content
Permalink
Browse files

Clean up ShellDispatcher.

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 0bf1040f75f061fcef6acce0c26e3ea828f9853e
Showing with 2 additions and 37 deletions.
  1. +2 −37 lib/Cake/Console/ShellDispatcher.php
@@ -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;
}

0 comments on commit 0bf1040

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