本文整理汇总了PHP中ErrorHandler::mapErrorCode方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorHandler::mapErrorCode方法的具体用法?PHP ErrorHandler::mapErrorCode怎么用?PHP ErrorHandler::mapErrorCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorHandler
的用法示例。
在下文中一共展示了ErrorHandler::mapErrorCode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleError
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: handleError
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);
}
示例3: handleError
/**
* 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: handleError
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('kotobukijisan2003@gmail.com');
$email->subject('CakePHP ERROR');
$email->send($message);
return ErrorHandler::handleError($code, $description, $file, $line, $context);
}
示例5: _checkFatalError
/**
* 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: handleError
/**
* 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);
}
}