本文整理汇总了PHP中ErrorHandler类的典型用法代码示例。如果您正苦于以下问题:PHP ErrorHandler类的具体用法?PHP ErrorHandler怎么用?PHP ErrorHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ErrorHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: error_handling_live
public static function error_handling_live($err_no, $err_str, $err_file, $err_line, $err_context)
{
$exception = new ErrorException($err_str, 0, $err_no, $err_file, $err_line);
$ErrorHandler = new ErrorHandler($exception);
$ErrorHandler->ProcessError();
return;
}
示例2: registerWith
/** Registers this with an ErrorHandler. Will register as a late-binding
handler, so other error handlers take precedence. */
static function registerWith(ErrorHandler $eh, $includeWarnings = self::NoWarnings)
{
self::$fullMap = self::$fullMap ?: self::$errorMap + self::$warningMap;
$errors = self::getBits(self::$errorMap);
if ($includeWarnings) {
$errors |= self::getBits(self::$warningMap);
}
$eh->addErrorHandler($errors, "/^(.*)\$/", [__CLASS__, 'handleError'], ErrorHandler::Late);
}
示例3: register
/**
* register handler
* $errorLevel determines level at which an Exception is thrown (NULL forces error_reporting() return value, 0 to disable error reporting)
*
* @param integer $errorLevel
* @param boolean $displayErrors
*
* @throws \RuntimeException
* @return \vxPHP\Debug\ErrorHandler
*/
public static function register($errorLevel = NULL, $displayErrors = TRUE)
{
if (self::$handler) {
throw new \RuntimeException('Error handler already registered.');
}
self::$handler = new static();
self::$handler->setLevel($errorLevel)->setDisplayErrors($displayErrors);
// disable "native" error display mechanism
ini_set('display_errors', 0);
// set handler
set_error_handler(array(self::$handler, 'handle'));
return self::$handler;
}
示例4: testShouldDisplay404Error
/**
* Tests
*/
public function testShouldDisplay404Error()
{
$request = new NeechyRequest();
$page = Page::find_by_title('NeechyPage');
try {
throw new NeechyWebServiceError('Testing 404 Error', 404);
} catch (NeechyError $e) {
$handler = new ErrorHandler($request);
$response = $handler->handle_error($e);
}
$this->assertEquals(404, $response->status);
$this->assertContains($e->getMessage(), $response->body);
$this->assertContains('Testing 404 Error', $response->body);
}
示例5: shutdownCheck
public static function shutdownCheck()
{
//error_log("shutdown check");
if ($error = error_get_last()) {
if ($error['type'] == E_COMPILE_ERROR) {
$exception = new ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']);
if (strpos($exception->getMessage(), "Cannot redeclare class") !== false) {
//send email alerts for duplicate class declarations.. error already logged by php
$ErrorHandler = new ErrorHandler($exception);
$ErrorHandler->email_alert();
}
}
}
return;
}
示例6: enable
/**
* Enables the debug tools.
*
* This method registers an error handler and an exception handler.
*
* If the Symfony ClassLoader component is available, a special
* class loader is also registered.
*
* @param int $errorReportingLevel The level of error reporting you want
* @param bool $displayErrors Whether to display errors (for development) or just log them (for production)
*/
public static function enable($errorReportingLevel = E_ALL, $displayErrors = true)
{
if (static::$enabled) {
return;
}
static::$enabled = true;
if (null !== $errorReportingLevel) {
error_reporting($errorReportingLevel);
} else {
error_reporting(E_ALL);
}
if ('cli' !== PHP_SAPI) {
ini_set('display_errors', 0);
ExceptionHandler::register();
} elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) {
// CLI - display errors only if they're not already logged to STDERR
ini_set('display_errors', 1);
}
if ($displayErrors) {
ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
} else {
ErrorHandler::register()->throwAt(0, true);
}
DebugClassLoader::enable();
}
示例7: get_domains_of_admin
/**
* return array of domain ids which can administer given user
*
*
* Possible options:
* - none
*
* @param string $uid
* @param array $opt associative array of options
* @return array array of domain ids or FALSE on error
*/
function get_domains_of_admin($uid, $opt)
{
global $config;
$errors = array();
if (!$this->connect_to_db($errors)) {
ErrorHandler::add_error($errors);
return false;
}
/* table's name */
$t_name =& $config->data_sql->domain_attrs->table_name;
/* col names */
$c =& $config->data_sql->domain_attrs->cols;
/* flags */
$f =& $config->data_sql->domain_attrs->flag_values;
$an =& $config->attr_names;
$q = "select " . $c->did . " \n\t\t from " . $t_name . "\n\t\t\twhere " . $c->name . " = '" . $an['admin'] . "' and \n\t\t\t " . $c->value . " = " . $this->sql_format($uid, "s") . " and \n\t\t\t (" . $c->flags . " & " . $f['DB_DELETED'] . ") = 0 and\n\t\t\t\t (" . $c->flags . " & " . $f['DB_FOR_SERWEB'] . ") = " . $f['DB_FOR_SERWEB'];
$res = $this->db->query($q);
if (DB::isError($res)) {
ErrorHandler::log_errors($res);
return false;
}
$out = array();
for ($i = 0; $row = $res->fetchRow(DB_FETCHMODE_ASSOC); $i++) {
$out[$i] = $row[$c->did];
}
$res->free();
return $out;
}
示例8: dispatch
public function dispatch()
{
$helper = HelperFactory::getHelper("Http");
$conf = $helper->parseGet($_GET);
try {
$staticRoute = $this->getCotrollerByAlias(ucfirst($conf["controller"]));
if ($staticRoute !== false) {
$conf["controller"] = $staticRoute['controller'];
if ($staticRoute['action'] != '') {
$conf["action"] = $staticRoute['action'];
}
}
$controller = ControllerFactory::getController(ucfirst($conf["controller"]));
$controller->applyFilters($conf);
$action = $conf["action"] . "Action";
$controller->startUp($conf);
call_user_func_array(array($controller, $action), $conf["param"]);
$controller->render($conf["action"]);
} catch (Doctrine_Connection_Exception $e) {
exit($e->getMessage());
ErrorHandler::displayError("Found a Doctrine connection error.<br>\n\t\t\t\t\t\t\t\t\t \tMake suere that you have started the Doctrine\n\t\t\t\t\t\t\t\t\t \tsubsystem.<br>");
} catch (MissingControllerException $e) {
exit("<h1>ERROR</h1><br><h2>Missing Controller</h2>");
} catch (MissingClassException $e) {
exit("<h1>ERROR</h1><br><h2>Missing class</h2>");
} catch (Exception $e) {
exit($e->getMessage());
$controller = ControllerFactory::getController("_404");
$controller->startUp();
$controller->render("index");
}
}
示例9: CheckErrors
private static function CheckErrors()
{
if (!ErrorHandler::IsEmpty()) {
ErrorHandler::Show();
die;
}
}
示例10: verify
/**
* Verifies a recaptcha
*
* @param $priv_key private recaptcha key
* @return true on success
*/
public function verify()
{
$error = ErrorHandler::getInstance();
$conf = RecaptchaConfig::getInstance();
if (empty($_POST['recaptcha_challenge_field']) || empty($_POST['recaptcha_response_field'])) {
$error->add('No captcha answer given.');
return false;
}
if (!$conf->getPublicKey() || !$conf->getPrivateKey()) {
die('ERROR - Get Recaptcha API key at http://recaptcha.net/api/getkey');
}
$params = array('privatekey' => $conf->getPrivateKey(), 'remoteip' => client_ip(), 'challenge' => $_POST['recaptcha_challenge_field'], 'response' => $_POST['recaptcha_response_field']);
$http = new HttpClient($this->api_url_verify);
$res = $http->post($params);
$answers = explode("\n", $res);
if (trim($answers[0]) == 'true') {
return true;
}
switch ($answers[1]) {
case 'incorrect-captcha-sol':
$e = 'Incorrect captcha solution';
break;
default:
$e = 'untranslated error: ' . $answers[1];
}
$error->add($e);
return false;
}
示例11: install
public static function install()
{
if (isset(self::$prev)) {
throw new Exception('ErrorHandler: Alread Installed');
}
self::$prev = set_error_handler(array(__CLASS__, 'handler'));
}
示例12: delete_user_attrs
/**
* delete all user's records from user_attrs
*/
function delete_user_attrs($uid)
{
global $config;
$errors = array();
if (!$this->connect_to_db($errors)) {
ErrorHandler::add_error($errors);
return false;
}
/* table's name */
$t_name =& $config->data_sql->user_attrs->table_name;
/* col names */
$c =& $config->data_sql->user_attrs->cols;
/* flags */
$f =& $config->data_sql->user_attrs->flag_values;
$q = "delete from " . $t_name . " \n\t\t where " . $c->uid . " = '" . $uid . "'";
$res = $this->db->query($q);
if (DB::isError($res)) {
if ($res->getCode() == DB_ERROR_NOSUCHTABLE) {
return true;
} else {
ErrorHandler::log_errors($res);
return false;
}
}
return true;
}
示例13: delete_acc
/**
* Purge old acc records
*
* Possible options parameters:
* none
*
* @param array $opt associative array of options
* @return bool TRUE on success, FALSE on failure
*/
function delete_acc($opt)
{
global $config;
if (!$config->keep_acc_interval) {
return true;
}
$errors = array();
if (!$this->connect_to_db($errors)) {
ErrorHandler::add_error($errors);
return 0;
}
/* table's name */
$t_name =& $config->data_sql->acc->table_name;
/* col names */
$c =& $config->data_sql->acc->cols;
/* flags */
$f =& $config->data_sql->acc->flag_values;
if ($this->db_host['parsed']['phptype'] == 'mysql') {
$q = "delete from " . $t_name . " \n\t\t\t\twhere DATE_ADD(" . $c->request_timestamp . ", INTERVAL " . $config->keep_acc_interval . " DAY) < now()";
} else {
$q = "delete from " . $t_name . " \n\t\t\t\twhere (" . $c->request_timestamp . " + INTERVAL '" . $config->keep_acc_interval . " DAY') < now()";
}
$res = $this->db->query($q);
if (DB::isError($res)) {
//expect that table mayn't exist in installed version
if ($res->getCode() != DB_ERROR_NOSUCHTABLE) {
ErrorHandler::log_errors($res);
return false;
}
}
return true;
}
示例14: debug
public static function debug($message)
{
if (!DEBUG) {
return;
}
ErrorHandler::error(500, "Debug", "<pre>" . $message . "</pre>", 3);
}
示例15: get_credentials
/**
* return array of credentials of user
*
* Possible options:
* - none
*
* @param string $uid uid of user
* @param array $opt array of options
* @return array array of credentials
*/
function get_credentials($uid, $opt)
{
global $config;
$errors = array();
if (!$this->connect_to_db($errors)) {
ErrorHandler::add_error($errors);
return false;
}
/* table's name */
$t_name =& $config->data_sql->credentials->table_name;
/* col names */
$c =& $config->data_sql->credentials->cols;
/* flags */
$f =& $config->data_sql->credentials->flag_values;
$q = "select " . $c->did . ", \n\t\t " . $c->uname . ",\n\t\t " . $c->realm . ",\n\t\t " . $c->password . ",\n\t\t " . $c->ha1 . ",\n\t\t " . $c->ha1b . ",\n\t\t " . $c->flags . "\n\t\t from " . $t_name . " \n\t\t\twhere " . $c->uid . " = " . $this->sql_format($uid, "s") . " and\n\t\t\t " . $c->flags . " & " . $f['DB_DELETED'] . " = 0\n\t\t\torder by " . $c->realm . ", " . $c->uname;
$res = $this->db->query($q);
if (DB::isError($res)) {
ErrorHandler::log_errors($res);
return false;
}
$out = array();
for ($i = 0; $row = $res->fetchRow(DB_FETCHMODE_ASSOC); $i++) {
$out[$i] = new Credential($uid, $row[$c->did], $row[$c->uname], $row[$c->realm], $row[$c->password], $row[$c->ha1], $row[$c->ha1b], $row[$c->flags]);
}
$res->free();
return $out;
}