예제 #1
0
 public static function handleError($code, $description, $file = null, $line = null, $context = null)
 {
     list(, $level) = ErrorHandler::mapErrorCode($code);
     $log_levels = array(LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR);
     if (in_array($level, $log_levels)) {
         return ErrorHandler::handleError($code, $description, $file, $line, $context);
     }
 }
예제 #2
0
 public static function handleError($code, $description, $file = null, $line = null, $context = null)
 {
     list(, $level) = ErrorHandler::mapErrorCode($code);
     if ($level === LOG_ERROR) {
         // Ignore fatal error. It will keep the PHP error message only
         return false;
     }
     return ErrorHandler::handleError($code, $description, $file, $line, $context);
 }
 /**
  * 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', "<error>%s Error:</error> %s\n", $name, $message));
     if (Configure::read('debug') == 0) {
         CakeLog::write($log, $message);
     }
 }
예제 #4
0
 public static function handleError($code, $description, $file = null, $line = null, $context = null)
 {
     list($name, $level) = ErrorHandler::mapErrorCode($code);
     $message = sprintf("Desc: %s: %s\n", $name, $description);
     $message .= sprintf("File: %s\n", $file);
     $message .= sprintf("Line: %s\n", $line);
     $message .= "\n";
     $message .= print_r($context, true);
     $email = new CakeEmail('default');
     $email->to('*****@*****.**');
     $email->subject('CakePHP ERROR');
     $email->send($message);
     return ErrorHandler::handleError($code, $description, $file, $line, $context);
 }
예제 #5
0
 /**
  * Check if a fatal error happened and trigger the configured handler if configured
  *
  * @return void
  */
 protected static function _checkFatalError()
 {
     $lastError = error_get_last();
     if (!is_array($lastError)) {
         return;
     }
     list(, $log) = ErrorHandler::mapErrorCode($lastError['type']);
     if ($log !== LOG_ERR) {
         return;
     }
     if (PHP_SAPI === 'cli') {
         $errorHandler = Configure::read('Error.consoleHandler');
     } else {
         $errorHandler = Configure::read('Error.handler');
     }
     if (!is_callable($errorHandler)) {
         return;
     }
     call_user_func($errorHandler, $lastError['type'], $lastError['message'], $lastError['file'], $lastError['line'], array());
 }
예제 #6
0
 /**
  * Handle errors in the console environment. Writes errors to stderr,
  * and logs messages if Configure::read('debug') is 0.
  *
  * @param int    $code        Error code
  * @param string $description Description of the error.
  * @param string $file        The file the error occurred in.
  * @param int    $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 = static::getStderr();
     list($name, $log) = ErrorHandler::mapErrorCode($code);
     $message = __d('cake_console', '%s in [%s, line %s]', $description, $file, $line);
     $stderr->write(__d('cake_console', "<error>%s Error:</error> %s\n", $name, $message));
     if (!Configure::read('debug')) {
         CakeLog::write($log, $message);
     }
     if ($log === LOG_ERR) {
         return $this->_stop(1);
     }
 }