• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP MWException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: report

 /**
  * Overrides MWException::report to also write exceptions to error_log
  *
  * @see  MWException::report
  */
 function report()
 {
     $file = $this->getFile();
     $line = $this->getLine();
     $message = $this->getMessage();
     $request = RequestContext::getMain()->getRequest();
     $url = '[no URL]';
     if (isset($request)) {
         $url = $request->getFullRequestURL();
     }
     trigger_error("Exception from line {$line} of {$file}: {$message} ({$url})", E_USER_ERROR);
     /*
     bust the headers_sent check in MWException::report()
     Uncomment to override normal MWException headers
     in order to display an error page instead of a 500 error
     WARNING: Varnish doesn't like those
     flush();
     */
     parent::report();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:25,代码来源:WikiaException.php


示例2: report

 /**
  * Report an exception to the user
  * @param Exception $e
  */
 protected static function report(Exception $e)
 {
     global $wgShowExceptionDetails;
     $cmdLine = MWException::isCommandLine();
     if ($e instanceof MWException) {
         try {
             // Try and show the exception prettily, with the normal skin infrastructure
             $e->report();
         } catch (Exception $e2) {
             // Exception occurred from within exception handler
             // Show a simpler message for the original exception,
             // don't try to invoke report()
             $message = "MediaWiki internal error.\n\n";
             if ($wgShowExceptionDetails) {
                 $message .= 'Original exception: ' . self::getLogMessage($e) . "\nBacktrace:\n" . self::getRedactedTraceAsString($e) . "\n\nException caught inside exception handler: " . self::getLogMessage($e2) . "\nBacktrace:\n" . self::getRedactedTraceAsString($e2);
             } else {
                 $message .= "Exception caught inside exception handler.\n\n" . "Set \$wgShowExceptionDetails = true; at the bottom of LocalSettings.php " . "to show detailed debugging information.";
             }
             $message .= "\n";
             if ($cmdLine) {
                 self::printError($message);
             } else {
                 echo nl2br(htmlspecialchars($message)) . "\n";
             }
         }
     } else {
         $message = "Exception encountered, of type \"" . get_class($e) . "\"";
         if ($wgShowExceptionDetails) {
             $message .= "\n" . MWExceptionHandler::getLogMessage($e) . "\nBacktrace:\n" . self::getRedactedTraceAsString($e) . "\n";
         }
         if ($cmdLine) {
             self::printError($message);
         } else {
             echo nl2br(htmlspecialchars($message)) . "\n";
         }
     }
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:41,代码来源:MWExceptionHandler.php


示例3: testisCommandLine

 /**
  * @dataProvider provideIsCommandLine
  * @covers MWException::isCommandLine
  */
 public function testisCommandLine($expected, $wgCommandLineMode)
 {
     $this->setMwGlobals(array('wgCommandLineMode' => $wgCommandLineMode));
     $e = new MWException();
     $this->assertEquals($expected, $e->isCommandLine());
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:10,代码来源:MWExceptionTest.php


示例4: report

 /**
  * Override MWException report() and write exceptions to error_log
  *
  * Uncomment the flush() line to override normal MWException headers
  * so we can display an error page instead of a 500 error (varnish doesn't like those)
  *
  * TODO: display a nice walter?
  */
 function report()
 {
     global $wgRequest;
     $file = $this->getFile();
     $line = $this->getLine();
     $message = $this->getMessage();
     $url = '[no URL]';
     if (isset($wgRequest)) {
         $url = $wgRequest->getFullRequestURL();
     }
     trigger_error("Exception from line {$line} of {$file}: {$message} ({$url})", E_USER_ERROR);
     //flush();   // bust the headers_sent check in MWException::report()
     parent::report();
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:22,代码来源:WikiaException.php


示例5: report

 /**
  * Report an exception to the user
  */
 protected static function report(Exception $e)
 {
     global $wgShowExceptionDetails;
     $cmdLine = MWException::isCommandLine();
     if ($e instanceof MWException) {
         try {
             // Try and show the exception prettily, with the normal skin infrastructure
             $e->report();
         } catch (Exception $e2) {
             // Exception occurred from within exception handler
             // Show a simpler error message for the original exception,
             // don't try to invoke report()
             $message = "MediaWiki internal error.\n\n";
             if ($wgShowExceptionDetails) {
                 $message .= 'Original exception: ' . $e->__toString() . "\n\n" . 'Exception caught inside exception handler: ' . $e2->__toString();
             } else {
                 $message .= "Exception caught inside exception handler.\n\n" . "Set \$wgShowExceptionDetails = true; at the bottom of LocalSettings.php " . "to show detailed debugging information.";
             }
             $message .= "\n";
             if ($cmdLine) {
                 self::printError($message);
             } else {
                 self::escapeEchoAndDie($message);
             }
         }
     } else {
         $message = "Unexpected non-MediaWiki exception encountered, of type \"" . get_class($e) . "\"\n" . $e->__toString() . "\n";
         if ($wgShowExceptionDetails) {
             $message .= "\n" . $e->getTraceAsString() . "\n";
         }
         if ($cmdLine) {
             self::printError($message);
         } else {
             self::escapeEchoAndDie($message);
         }
     }
 }
开发者ID:yusufchang,项目名称:app,代码行数:40,代码来源:Exception.php


示例6: __construct

 /**
  * Constructor
  *
  * @param int $httpCode HTTP status code to send to the client
  * @param string|Message $content Content of the message
  * @param string|Message|null $header Content of the header (\<title\> and \<h1\>)
  */
 public function __construct($httpCode, $content, $header = null)
 {
     parent::__construct($content);
     $this->httpCode = (int) $httpCode;
     $this->header = $header;
     $this->content = $content;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:14,代码来源:HttpError.php


示例7: __construct

 /**
  * @todo Pass around Messages when Status class doesn't suck
  * @param array $msg Message key with parameters
  */
 public function __construct(array $msg)
 {
     $this->msg = $msg;
     // Using ->plain() instead of ->text() due to bug T58226
     $wikitext = call_user_func_array('wfMessage', $msg)->plain();
     parent::__construct($wikitext);
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:11,代码来源:TPException.php


示例8:

 /**
  * Construct a database error
  * @param $db DatabaseBase object which threw the error
  * @param $error String A simple error message to be used for debugging
  */
 function __construct(DatabaseBase &$db, $error)
 {
     global $wgDBcluster;
     $this->db = $db;
     parent::__construct($error);
     $isMaster = !is_null($db->getLBInfo('master'));
     // Wikia change - @author macbre - MAIN-2304
     \Wikia\Logger\WikiaLogger::instance()->error('DBError', ['name' => $db->getDBname(), 'cluster' => $wgDBcluster, 'server' => $db->getServer(), 'server_role' => $isMaster ? 'master' : 'slave', 'errno' => $db->lastErrno(), 'err' => $db->lastError(), 'exception' => $this]);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:DatabaseError.php


示例9: getHTML

 function getHTML()
 {
     global $wgShowExceptionDetails;
     $class = strtolower(get_class($this->getPrevious()));
     $box_content = wfMessage($class . '-body')->text();
     $box = '<div class="errorbox" style="float: none;">' . $box_content . "</div>";
     if ($wgShowExceptionDetails) {
         $box .= '<b>Status code:</b> ' . $this->previous->getCode() . "<br /><b>Message from authentication server:</b> " . $this->previous->getMessage();
     }
     return $box . parent::getHTML();
 }
开发者ID:somenet,项目名称:MediaWiki,代码行数:11,代码来源:RestAuthError.php


示例10: array

 function __construct($exceptionID, $engine, $module = null, $line = null, $params = array())
 {
     if ($module) {
         $codelocation = wfMsg('scripting-codelocation', $module, $line);
         $msg = wfMsgExt("scripting-exception-{$engine}-{$exceptionID}", array(), array_merge(array($codelocation), $params));
     } else {
         $msg = wfMsgExt("scripting-exception-{$engine}-{$exceptionID}", array(), $params);
     }
     parent::__construct($msg);
     $this->mExceptionID = $exceptionID;
     $this->mLine = $line;
     $this->mModule = $module;
     $this->mParams = $params;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:14,代码来源:Common.php


示例11: __construct

 /**
  * Note: these arguments are keys into wfMessage(), not text!
  *
  * @param string|Message $title Message key (string) for page title, or a Message object
  * @param string|Message $msg Message key (string) for error text, or a Message object
  * @param array $params Array with parameters to wfMessage()
  */
 public function __construct($title, $msg, $params = [])
 {
     $this->title = $title;
     $this->msg = $msg;
     $this->params = $params;
     // Bug 44111: Messages in the log files should be in English and not
     // customized by the local wiki. So get the default English version for
     // passing to the parent constructor. Our overridden report() below
     // makes sure that the page shown to the user is not forced to English.
     if ($msg instanceof Message) {
         $enMsg = clone $msg;
     } else {
         $enMsg = wfMessage($msg, $params);
     }
     $enMsg->inLanguage('en')->useDatabase(false);
     parent::__construct($enMsg->text());
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:24,代码来源:ErrorPageError.php


示例12: array

 /**
  * @param string $messageName
  * @param array $params
  */
 function __construct($messageName, $params = array())
 {
     if (isset($params['args'])) {
         $this->messageArgs = $params['args'];
     } else {
         $this->messageArgs = array();
     }
     if (isset($params['module']) && isset($params['line'])) {
         $codeLocation = false;
         if (isset($params['title'])) {
             $moduleTitle = Title::newFromText($params['module']);
             if ($moduleTitle && $moduleTitle->equals($params['title'])) {
                 $codeLocation = wfMessage('scribunto-line', $params['line'])->inContentLanguage()->text();
             }
         }
         if ($codeLocation === false) {
             $codeLocation = wfMessage('scribunto-module-line', $params['module'], $params['line'])->inContentLanguage()->text();
         }
     } else {
         $codeLocation = '[UNKNOWN]';
     }
     array_unshift($this->messageArgs, $codeLocation);
     $msg = wfMessage($messageName)->params($this->messageArgs)->inContentLanguage()->text();
     parent::__construct($msg);
     $this->messageName = $messageName;
     $this->params = $params;
 }
开发者ID:sammykumar,项目名称:TheVRForums,代码行数:31,代码来源:Common.php


示例13:

 /**
  * Construct a database error
  * @param Database $db The database object which threw the error
  * @param string $error A simple error message to be used for debugging
  */
 function __construct(Database &$db, $error)
 {
     $this->db =& $db;
     parent::__construct($error);
 }
开发者ID:puring0815,项目名称:OpenKore,代码行数:10,代码来源:Database.php


示例14: __construct

 /**
  * @param string $message
  * @param string $codestr
  * @param int $code
  * @param array|null $extradata
  */
 public function __construct($message, $codestr, $code = 0, $extradata = null)
 {
     parent::__construct($message, $code);
     $this->mCodestr = $codestr;
     $this->mExtraData = $extradata;
 }
开发者ID:soumyag213,项目名称:mediawiki,代码行数:12,代码来源:ApiMain.php


示例15:

 /**
  * Construct a database error
  * @param DatabaseBase $db Object which threw the error
  * @param string $error A simple error message to be used for debugging
  */
 function __construct(DatabaseBase $db = null, $error)
 {
     $this->db = $db;
     parent::__construct($error);
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:10,代码来源:DatabaseError.php


示例16:

 function __construct($message)
 {
     parent::__construct('CLDR plural rule error: ' . $message);
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:4,代码来源:CLDRPluralRuleEvaluator.php


示例17: __construct

	public function __construct( HTMLFormField $field, array $missing ) {
		parent::__construct( sprintf(
			"Form type `%s` expected the following parameters to be set: %s",
			get_class( $field ),
			implode( ', ', $missing )
		) );
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:7,代码来源:HTMLForm.php


示例18: __construct

	/**
	 * @param $msg \string Message key.
	 */
	public function __construct( $msg ) {
		$this->msg = $msg;
		parent::__construct( call_user_func_array( 'wfMsg', $msg ) );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:7,代码来源:TPException.php


示例19:

 /** @param string $modelId */
 function __construct($modelId)
 {
     parent::__construct("The content model '{$modelId}' is not registered on this wiki.\n" . 'See https://www.mediawiki.org/wiki/Content_handlers to find out which extensions ' . 'handle this content model.');
     $this->modelId = $modelId;
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:6,代码来源:ContentHandler.php


示例20:

 /**
  * Construct a database error
  * @param Database $db The database object which threw the error
  * @param string $error A simple error message to be used for debugging
  */
 function __construct($faultcode, $error = '')
 {
     $this->mFaultCode = $faultcode;
     $this->mFaultText = !empty($error) ? $error : $this->getApiFaultName();
     parent::__construct($this->mFaultText);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:11,代码来源:WikiaApiQuery.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP MWExceptionHandler类代码示例发布时间:2022-05-23
下一篇:
PHP MWDebug类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap