write(__d('cake_console', "Error: %s\n%s", $exception->getMessage(), $exception->getTraceAsString() )); return $this->_stop($exception->getCode() ? $exception->getCode() : 1); } /** * Handle errors in the console environment. Writes errors to stderr, * and logs messages if Configure::read('debug') is 0. * * @param integer $code Error code * @param string $description Description of the error. * @param string $file The file the error occurred in. * @param integer $line The line the error occurred on. * @param array $context The backtrace of the error. * @return void */ public function handleError($code, $description, $file = null, $line = null, $context = null) { if (error_reporting() === 0) { return; } $stderr = self::getStderr(); list($name, $log) = ErrorHandler::mapErrorCode($code); $message = __d('cake_console', '%s in [%s, line %s]', $description, $file, $line); $stderr->write(__d('cake_console', "%s Error: %s\n", $name, $message)); if (!Configure::read('debug')) { CakeLog::write($log, $message); } if ($log === LOG_ERR) { return $this->_stop(1); } } /** * Wrapper for exit(), used for testing. * * @param integer $code The exit code. * @return void */ protected function _stop($code = 0) { exit($code); } }