本文整理汇总了PHP中ErrorHandler::handleFailure方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorHandler::handleFailure方法的具体用法?PHP ErrorHandler::handleFailure怎么用?PHP ErrorHandler::handleFailure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorHandler
的用法示例。
在下文中一共展示了ErrorHandler::handleFailure方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleException
public static function handleException(Exception $e)
{
switch (get_class($e)) {
case 'RecordValidationException':
return static::handleValidationError($e);
default:
$report = sprintf("<h1 style='color:red'>%s caught</h1>\n", get_class($e));
$report .= sprintf("<h2>Details</h2>\n<pre>%s</pre>\n", print_r($e, true));
$report .= sprintf("<h2>URI</h2>\n<p>%s</p>\n", htmlspecialchars($_SERVER['REQUEST_URI']));
$report .= sprintf("<h2>_SERVER</h2>\n<pre>%s</pre>\n", print_r($_SERVER, true));
if ($GLOBALS['Session']->Person) {
$report .= sprintf("<h2>User</h2>\n<pre>%s</pre>\n", print_r($GLOBALS['Session']->Person->getData(), true));
}
$report .= ErrorHandler::formatBacktrace(debug_backtrace());
$report .= '<h2>Debug Log</h2><pre>' . print_r(DebugLog::getLog(), true) . '</pre>';
if (Site::$debug) {
die($report);
} else {
Email::send(Site::$webmasterEmail, 'Unhandeld ' . get_class($e) . ' on ' . $_SERVER['HTTP_HOST'], $report);
ErrorHandler::handleFailure('There was a problem... our technical staff has been notified. Please retry later.');
}
}
}
示例2: handleError
protected static function handleError($query = '', $queryLog = false)
{
// save queryLog
if ($queryLog) {
$queryLog['error'] = static::$_mysqli->error;
self::finishQueryLog($queryLog);
}
// get error message
if ($query == 'connect') {
$message = mysqli_connect_error();
} elseif (static::$_mysqli->errno == 1062) {
throw new DuplicateKeyException(static::$_mysqli->error);
} else {
$message = static::$_mysqli->error;
}
// respond
$report = sprintf("<h1 style='color:red'>Database Error</h1>\n");
$report .= sprintf("<h2>URI</h2>\n<p>%s</p>\n", htmlspecialchars($_SERVER['REQUEST_URI']));
$report .= sprintf("<h2>Query</h2>\n<p>%s</p>\n", htmlspecialchars($query));
$report .= sprintf("<h2>Reported</h2>\n<p>%s</p>\n", htmlspecialchars($message));
$report .= ErrorHandler::formatBacktrace(debug_backtrace());
if ($GLOBALS['Session']->Person) {
$report .= sprintf("<h2>User</h2>\n<pre>%s</pre>\n", var_export($GLOBALS['Session']->Person->data, true));
}
if (self::$DebugMode) {
print $report;
DebugLog::dumpLog();
exit;
} else {
Email::send(self::$AdministratorEmail, 'Database error on ' . $_SERVER['HTTP_HOST'], $report);
ErrorHandler::handleFailure('Error while communicating with database', ErrorHandler::ERROR_DB);
}
}