当前位置: 首页>>代码示例>>PHP>>正文


PHP ErrorHandler::handleException方法代码示例

本文整理汇总了PHP中ErrorHandler::handleException方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorHandler::handleException方法的具体用法?PHP ErrorHandler::handleException怎么用?PHP ErrorHandler::handleException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ErrorHandler的用法示例。


在下文中一共展示了ErrorHandler::handleException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handleException

 public static function handleException(Exception $exception)
 {
     // Call Bugsnag
     Bugsnag::exceptionHandler($exception);
     // Fall back to Cake..
     return parent::handleException($exception);
 }
开发者ID:morrislaptop,项目名称:bugsnag-cake,代码行数:7,代码来源:BugsnagError.php

示例2: renderFile

 public function renderFile()
 {
     header("Content-Type: application/json;charset=utf-8");
     $aRequest = array();
     $sContentType = 'application/x-www-form-urlencoded';
     if (isset($_SERVER['CONTENT_TYPE'])) {
         $sContentType = $_SERVER['CONTENT_TYPE'];
     }
     if (isset($_SERVER['HTTP_CONTENT_TYPE'])) {
         $sContentType = $_SERVER['HTTP_CONTENT_TYPE'];
     }
     if (StringUtil::startsWith($sContentType, 'application/json')) {
         $aRequest = json_decode(file_get_contents('php://input'), true);
     } else {
         foreach ($_REQUEST as $sKey => $sValue) {
             $aRequest[$sKey] = json_decode($sValue, true);
         }
     }
     $oSession = Session::getSession();
     if (!isset($aRequest['session_language']) && $oSession->isAuthenticated()) {
         $aRequest['session_language'] = $oSession->getUser()->getLanguageId();
     }
     $sPrevSessionLanguage = null;
     $sSetSessionLanguage = null;
     if (isset($aRequest['session_language'])) {
         $sPrevSessionLanguage = Session::language();
         $sSetSessionLanguage = $aRequest['session_language'];
         $oSession->setLanguage($sSetSessionLanguage);
     }
     try {
         try {
             $mJSONData = $this->getJSON($aRequest);
             $sResult = json_encode($mJSONData);
             $iError = json_last_error();
             if ($iError !== JSON_ERROR_NONE) {
                 throw new LocalizedException('wns.error.json', array('json_error' => $iError, 'json_error_message' => self::$JSON_ERRORS[$iError]));
             }
             print $sResult;
         } catch (Exception $e) {
             //Handle the gift, not the wrapping…
             if ($e->getPrevious()) {
                 throw $e->getPrevious();
             } else {
                 throw $e;
             }
         }
     } catch (LocalizedException $ex) {
         LinkUtil::sendHTTPStatusCode(500, 'Server Error');
         print json_encode(array('exception' => array('message' => $ex->getLocalizedMessage(), 'code' => $ex->getCode(), 'file' => $ex->getFile(), 'line' => $ex->getLine(), 'trace' => $ex->getTrace(), 'parameters' => $ex->getMessageParameters(), 'exception_type' => $ex->getExceptionType())));
     } catch (Exception $ex) {
         LinkUtil::sendHTTPStatusCode(500, 'Server Error');
         ErrorHandler::handleException($ex, true);
         print json_encode(array('exception' => array('message' => "Exception when trying to execute the last action {$ex->getMessage()}", 'code' => $ex->getCode(), 'file' => $ex->getFile(), 'line' => $ex->getLine(), 'trace' => $ex->getTrace(), 'exception_type' => get_class($ex))));
     }
     //If we changed the session language and no widget willfully changed it as well, reset it to the previous state
     if ($sPrevSessionLanguage !== null && Session::language() === $sSetSessionLanguage) {
         $oSession->setLanguage($sPrevSessionLanguage);
     }
 }
开发者ID:rapila,项目名称:cms-base,代码行数:59,代码来源:WidgetJsonFileModule.php

示例3: handle

 /**
  * This method will handle any Exception thrown.
  *
  * @param Exception $exception The exception to be handled
  *
  * @return void
  */
 public static function handle($exception)
 {
     // Verify if the debug level is at least the minDebugLevel
     if (Configure::read('debug') >= self::$minDebugLevel) {
         // Debug level is high enough, use the Whoops handler
         $Whoops = new Whoops\Run();
         $Whoops->pushHandler(new Whoops\Handler\PrettyPageHandler());
         $Whoops->handleException($exception);
     } else {
         // Debug level is too low, fall back to CakePHP default ErrorHandler
         ErrorHandler::handleException($exception);
     }
 }
开发者ID:TamasBarta,项目名称:WhoopsCakephp,代码行数:20,代码来源:WhoopsExceptionHandler.php

示例4: handleException

 public static function handleException(Exception $exception)
 {
     try {
         // Avoid bot scan errors
         if (Configure::read('Sentry.avoid_bot_scan_errors') && ($exception instanceof MissingControllerException || $exception instanceof MissingPluginException) && Configure::read('debug') == 0) {
             echo Configure::read('Sentry.avoid_bot_scan_errors');
             exit(0);
         }
         self::sentryLog($exception);
         return parent::handleException($exception);
     } catch (Exception $e) {
         return parent::handleException($e);
     }
 }
开发者ID:parallax,项目名称:cake-sentry,代码行数:14,代码来源:SentryErrorHandler.php

示例5: initErrorHandlers

 /**
  * This method will be executed to set up the error handlers
  *
  * @static
  * @access public
  * @return void
  */
 private static function initErrorHandlers()
 {
     set_exception_handler(function ($e) {
         require_once 'ErrorHandler.php';
         ErrorHandler::handleException($e);
     });
     set_error_handler(function ($code, $error, $file, $line) {
         require_once 'ErrorHandler.php';
         ErrorHandler::handleNormalError($code, $error, $file, $line);
     });
     register_shutdown_function(function () {
         require_once 'ErrorHandler.php';
         ErrorHandler::handleShutdown();
     });
 }
开发者ID:xdbas,项目名称:restwork,代码行数:22,代码来源:Application.php

示例6: handleException

 public static function handleException(Exception $exception)
 {
     //MissingControllerException 方法的一般都是无效的访问,丢出去
     if ($exception instanceof MissingControllerException || $exception instanceof MissingActionException || $exception instanceof MissingViewException) {
         header("HTTP/1.0 404 Not Found");
         echo "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>404 Not Found</title></head><body><div align=\"center\"><a href=\"/\"><img src=\"/img/button/404.gif\" border=\"0\" /></a></div></body></html>";
         exit;
     }
     $config = Configure::read('Exception');
     if (@$config['log']) {
         $slow_log = "";
         $slow_log .= "\nHTTP_HOST  http://" . @(@$_SERVER['HTTP_X_REAL_HOST'] ? @$_SERVER['HTTP_X_REAL_HOST'] : $_SERVER['HTTP_HOST']) . @$_SERVER["REQUEST_URI"];
         $slow_log .= "\nHTTP_REFERER= " . @$_SERVER["HTTP_REFERER"];
         $slow_log .= "\nHTTP_USER_AGENT= " . @$_SERVER["HTTP_USER_AGENT"];
         $slow_log .= "\nSCRIPT_FILENAME= " . @$_SERVER["SCRIPT_FILENAME"];
         $slow_log .= var_export(@$_POST, true);
         $slow_log .= var_export(@$_GET, true);
         CakeLog::write(LOG_ERR, $slow_log);
     }
     parent::handleException($exception);
 }
开发者ID:RichardPear,项目名称:todo,代码行数:21,代码来源:AppExceptionHandler.php

示例7: getPageData

 public function getPageData()
 {
     $oPage = PageQuery::create()->findPk($this->iPageId);
     $aResult = $oPage->toArray(BasePeer::TYPE_PHPNAME, false);
     // addition related page fields
     $aResult['PageLink'] = LinkUtil::absoluteLink(LinkUtil::link($oPage->getFullPathArray(), 'FrontendManager', array(), AdminManager::getContentLanguage()), null, 'auto');
     $aResult['PageHref'] = LinkUtil::absoluteLink(LinkUtil::link($oPage->getFullPathArray(), 'FrontendManager', array(), AdminManager::getContentLanguage()), null, 'default', true);
     // page properties are displayed if added to template
     try {
         $mAvailableProperties = $this->getAvailablePageProperties($oPage);
         if (count($mAvailableProperties) > 0) {
             $aResult['page_properties'] = $mAvailableProperties;
         }
     } catch (Exception $e) {
         ErrorHandler::handleException($e, true);
     }
     // page references are displayed if exist
     $mReferences = AdminModule::getReferences(ReferencePeer::getReferences($oPage));
     $aResult['CountReferences'] = count($mReferences);
     if ($mReferences !== null) {
         $aResult['page_references'] = $mReferences;
     }
     return $aResult;
 }
开发者ID:rapila,项目名称:cms-base,代码行数:24,代码来源:PageDetailWidgetModule.php

示例8: testHandleExceptionLog

 /**
  * test handleException generating a page.
  *
  * @return void
  */
 function testHandleExceptionLog()
 {
     if ($this->skipIf(file_exists(APP . 'app_error.php'), 'App error exists cannot run.')) {
         return;
     }
     if (file_exists(LOGS . 'error.log')) {
         unlink(LOGS . 'error.log');
     }
     Configure::write('Exception.log', true);
     $error = new NotFoundException('Kaboom!');
     ob_start();
     ErrorHandler::handleException($error);
     $result = ob_get_clean();
     $this->assertPattern('/Kaboom!/', $result, 'message missing.');
     $log = file(LOGS . 'error.log');
     $this->assertPattern('/\\[NotFoundException\\] Kaboom!/', $log[0], 'message missing.');
     $this->assertPattern('/\\#0.*ErrorHandlerTest->testHandleExceptionLog/', $log[1], 'Stack trace missing.');
 }
开发者ID:robotarmy,项目名称:Phog,代码行数:23,代码来源:error_handler.test.php

示例9: set_error_handler

#!/usr/bin/env php
<?php 
require_once __DIR__ . '/../../../base/lib/inc.php';
try {
    set_error_handler(array('ErrorHandler', "handleError"));
    foreach (LanguageQuery::create()->filterByIsActive(true)->find() as $oLanguage) {
        $sLanguageId = $oLanguage->getId();
        $oModule = new UpdateSearchIndexFileModule(array(), $sLanguageId, true);
        $oModule->renderFile();
    }
} catch (Exception $oException) {
    ErrorHandler::handleException($oException);
}
开发者ID:rapila,项目名称:plugin-full_text_search,代码行数:13,代码来源:search_index_daily.php

示例10: handleException

 public static function handleException(Exception $exception)
 {
     $errbitCake = new ErrbitCakePHP();
     $errbitCake->onException($exception);
     return parent::handleException($exception);
 }
开发者ID:vinco,项目名称:vo-errbit-cake,代码行数:6,代码来源:ErrbitCakePHP.php

示例11: handleException

 /**
  * @see ErrorHandler::handleException
  */
 public static function handleException($exception)
 {
     // Check if the exception is not in the `ignoredExceptions` array
     $ignoredExceptions = Configure::read('Sentry.ignoredExceptions');
     if (!$ignoredExceptions) {
         $ignoredExceptions = array();
     }
     $className = get_class($exception);
     $eventId = true;
     if (!in_array($className, $ignoredExceptions)) {
         $eventId = self::sentryCapture($exception);
     }
     if ($eventId !== null) {
         parent::handleException($exception);
     }
 }
开发者ID:bond-os,项目名称:cakephp-sentry,代码行数:19,代码来源:SentryErrorHandler.php

示例12: handle

 public static function handle($error, $message = null)
 {
     $SeoAppError = new SeoAppError();
     if ($error->code == 404) {
         $SeoAppError->catch404();
         $SeoAppError->runLevenshtein();
     }
     $text = $message ? $message : $error->message;
     ErrorHandler::handleException($error);
 }
开发者ID:ashutoshdev,项目名称:openrug.com,代码行数:10,代码来源:SeoAppError.php

示例13: handleException

 public static function handleException($e)
 {
     ErrorHandler::handleException($e);
 }
开发者ID:JarvusInnovations,项目名称:Emergence-preview,代码行数:4,代码来源:MICS.class.php

示例14: handleException

 public static function handleException(Exception $exception)
 {
     self::bugsnagHandleException($exception);
     return parent::handleException($exception);
 }
开发者ID:howtv,项目名称:bugsnag-cakephp,代码行数:5,代码来源:BugsnagErrorHandler.php

示例15: ErrorHandler

<?php

namespace DYuriev;

/*
* @author: Dmitriy Yuriev <coolkid00@gmail.com>
* @product: error_handler
* @version: 1.1.1
* @release date: 27.07.2014
* @development started: 15.07.2014
* @license: GNU AGPLv3 <http://www.gnu.org/licenses/agpl.txt>
*
* A small useful library that helps to handle PHP fatal errors and exceptions.
* Supports messages on two languages: russian and english.
*/
error_reporting(-1);
ini_set("display_errors", "Off");
ini_set("display_startup_errors", "Off");
ini_set("html_errors", "Off");
define('ERROR_HANDLER_DIR', __DIR__);
require_once ERROR_HANDLER_DIR . '/class/ErrorHandler.class.php';
$error_handler = new ErrorHandler(\Swift_Mailer::newInstance(\Swift_MailTransport::newInstance()), \Swift_Message::newInstance());
set_error_handler(function ($err_no, $err_str, $err_file, $err_line) use($error_handler) {
    $error_handler->handleError($err_no, $err_str, $err_file, $err_line);
}, E_ALL | E_STRICT);
set_exception_handler(function ($exception) use($error_handler) {
    $error_handler->handleException($exception);
});
register_shutdown_function(function () use($error_handler) {
    $error_handler->handleShutdown();
});
开发者ID:dyuriev,项目名称:error_handler,代码行数:31,代码来源:error_handler_require.php


注:本文中的ErrorHandler::handleException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。