本文整理汇总了PHP中ErrorHandler::handleError方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorHandler::handleError方法的具体用法?PHP ErrorHandler::handleError怎么用?PHP ErrorHandler::handleError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorHandler
的用法示例。
在下文中一共展示了ErrorHandler::handleError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleError
public static function handleError($code, $description, $file = null, $line = null, $context = null)
{
// Call Bugsnag
Bugsnag::errorHandler($code, $description, $file, $line, $context);
// Fall back to cake
return parent::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);
$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);
}
}
示例3: handleError
public function handleError($code, $description, $file = null, $line = null, $context = null)
{
$cakePath = CAKE_CORE_INCLUDE_PATH . DS . CAKE;
if (ErrorHandler::handleError($code, $description, $file, $line, $context) !== false && !preg_match('!^' . $cakePath . '!', $file)) {
$this->handleException(new ErrorException($description, 0, $code, $file, $line));
return true;
}
return false;
}
示例4: 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);
}
示例5: handleError
public static function handleError($code, $description, $file = null, $line = null, $context = null)
{
try {
$e = new ErrorException($description, 0, $code, $file, $line);
self::sentryLog($e);
return parent::handleError($code, $description, $file, $line, $context);
} catch (Exception $e) {
self::handleException($e);
}
}
示例6: execute_request
function execute_request(Request $request, Response $response, $dispatchPath)
{
$dispatchList = (require $dispatchPath);
$result = Dispatcher::dispatch($dispatchList, $request);
if ($result[0] === false) {
$response->set_status_code(404);
$body = ErrorHandler::handleError(404, $request, 'Resource was not found');
$response->write($body);
return $response;
} else {
return \PHPMachine\DecisionCore::handleRequest($result[0], $request, $response);
}
}
示例7: 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);
}
示例8: handleError
/**
* This method is used as the central entry point to the APF's error management. It delegates the
* error handling to the registered handler. In case no handler is registered or the mechanism is
* disables, nothing will happen.
*
* @param int $errorNumber The error number.
* @param string $errorMessage The error message.
* @param string $errorFile The file the error occurred in.
* @param int $errorLine The line the error occurred at.
*
* @author Christian Achatz
* @version
* Version 0.1, 03.03.2012<br />
*/
public static function handleError($errorNumber, $errorMessage, $errorFile, $errorLine)
{
// Don't raise error, if @ was applied
if (error_reporting() == 0) {
return;
}
if (self::$HANDLER === null) {
// restore the PHP default error handler to avoid loops or other issues
restore_error_handler();
trigger_error($errorMessage, (int) $errorNumber);
} else {
self::$HANDLER->handleError($errorNumber, $errorMessage, $errorFile, $errorLine);
}
}
示例9: respond
protected static function respond($code, DecisionCoreState $state)
{
$request = $state->request;
$response = $state->response;
if ($code == 404) {
$response->write(ErrorHandler::handleError($code, $request, 'Resource was not found'));
} elseif ($code == 304) {
// TODO
// remove Content-Type header
// generate ETag
// Get Expires
}
$response->set_status_code($code);
static::callResource('finishRequest', $state);
$response->add_metadata('end-time', microtime(true));
return 'stop';
}
示例10: handleError
public static function handleError($code, $description, $file = null, $line = null, $context = null)
{
parent::handleError($code, $description, $file, $line, $context);
$errorConf = Configure::read('Error');
if (!($errorConf['level'] & $code)) {
return;
}
$force = Configure::read('ExceptionNotifier.force');
$debug = Configure::read('debug');
if (!$force && $debug > 0) {
return;
}
list($error, $log) = self::mapErrorCode($code);
$prefix = Configure::read('ExceptionNotifier.prefix');
$subject = $prefix . '[' . date('Ymd H:i:s') . '][' . strtoupper($error) . '][' . ExceptionText::getUrl() . '] ' . $description;
$body = ExceptionText::getBody($error . ':' . $description, $file, $line, $context);
return ExceptionMail::send($subject, $body);
}
示例11: testNotFoundPageShowsCorrectCopyWhenVerboseErrorsDisabled
public function testNotFoundPageShowsCorrectCopyWhenVerboseErrorsDisabled()
{
$original = Settings::getSettings();
$settings = $original;
$settings['errors']['verbose'] = false;
Settings::setFromArray($settings);
try {
$this->request->dispatch("/notfound");
} catch (Exception $e) {
$handler = new ErrorHandler();
$handler->setRequest($this->request);
$handler->handleError($e);
$this->assertResponseCode(404, $handler->getResponse());
$this->assertBodyHasContents("Oops! That’s a 404", $handler->getResponse());
$this->assertBodyHasContents("It looks like the page you’re after doesn’t exist", $handler->getResponse());
}
Settings::setFromArray($original);
}
示例12: handleError
/**
* HandleError
*
* @param integer $code Code of error
* @param string $description Error description
* @param string $file File on which error occurred
* @param integer $line Line that triggered the error
* @param array $context Context
* @return boolean true if error was handled
*/
public static function handleError($code, $description, $file = null, $line = null, $context = null)
{
extract(self::handlerSettings());
$args = compact('code', 'description', 'file', 'line', 'context', 'session');
if ($emailNotifications === true && !empty($receiver)) {
$cacheHash = 'error-' . md5(serialize(compact($args)));
self::setCacheConfig($duration);
if (Cache::read($cacheHash, 'error_handler') === false || $caching === false) {
list($error, $log) = self::mapErrorCode($code);
if (in_array($log, $logLevels) || in_array($code, $codes)) {
$trace = Debugger::trace(array('start' => 1, 'format' => 'log'));
$session = CakeSession::read();
$server = $_SERVER;
$request = $_REQUEST;
$Email = self::getEmailInstance();
$Email->viewVars(compact('code', 'description', 'file', 'line', 'context', 'session', 'server', 'request', 'trace'));
$Email->send();
}
Cache::write($cacheHash, true, 'error_handler');
}
}
return parent::handleError($code, $description, $file, $line, $context);
}
示例13: testHandleError
public function testHandleError()
{
$this->assertTrue(ErrorHandler::handleError('FooCode', 'FooMessage', 'FooFile', 'FooLine', 'FooContext'));
}
示例14: handleFatalError
/**
* shut down functions handler
*
*/
public static function handleFatalError()
{
$error = error_get_last();
ErrorHandler::handleError($error['type'], $error["message"], $error["file"], $error["line"]);
}
示例15: handleError
public static function handleError($code, $description, $file = null, $line = null, $context = null)
{
$errbitCake = new ErrbitCakePHP();
$errbitCake->onError($code, $description, $file, $line);
return parent::handleError($code, $description, $file, $line, $context);
}