本文整理汇总了PHP中MWException::isCommandLine方法的典型用法代码示例。如果您正苦于以下问题:PHP MWException::isCommandLine方法的具体用法?PHP MWException::isCommandLine怎么用?PHP MWException::isCommandLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MWException
的用法示例。
在下文中一共展示了MWException::isCommandLine方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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";
}
}
}
示例2: 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);
}
}
}
示例3: wfReportException
/**
* Report an exception to the user
*/
function wfReportException(Exception $e)
{
global $wgShowExceptionDetails;
$cmdLine = MWException::isCommandLine();
if ($e instanceof MWException) {
try {
$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) {
wfPrintError($message);
} else {
echo nl2br(htmlspecialchars($message)) . "\n";
}
}
} 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) {
wfPrintError($message);
} else {
echo nl2br(htmlspecialchars($message)) . "\n";
}
}
}
示例4: testisCommandLine
/**
* @dataProvider provideIsCommandLine
* @covers MWException::isCommandLine
*/
public function testisCommandLine($expected, $wgCommandLineMode)
{
$this->setMwGlobals(array('wgCommandLineMode' => $wgCommandLineMode));
$e = new MWException();
$this->assertEquals($expected, $e->isCommandLine());
}
示例5: wfReportException
/**
* Report an exception to the user
*/
function wfReportException(Exception $e)
{
$cmdLine = MWException::isCommandLine();
if ($e instanceof MWException) {
try {
$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 ($GLOBALS['wgShowExceptionDetails']) {
$message .= "Original exception: " . $e->__toString();
}
$message .= "\n\nException caught inside exception handler";
if ($GLOBALS['wgShowExceptionDetails']) {
$message .= ": " . $e2->__toString();
}
$message .= "\n";
if ($cmdLine) {
wfPrintError($message);
} else {
echo nl2br(htmlspecialchars($message)) . "\n";
}
}
} else {
$message = "Unexpected non-MediaWiki exception encountered, of type \"" . get_class($e) . "\"\n" . $e->__toString() . "\n";
if ($GLOBALS['wgShowExceptionDetails']) {
$message .= "\n" . $e->getTraceAsString() . "\n";
}
if ($cmdLine) {
wfPrintError($message);
} else {
echo nl2br(htmlspecialchars($message)) . "\n";
}
}
}