summaryrefslogtreecommitdiff
path: root/includes/Exception.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2006-10-11 20:21:25 +0000
committerPierre Schmitz <pierre@archlinux.de>2006-10-11 20:21:25 +0000
commitd81f562b712f2387fa02290bf2ca86392ab356f2 (patch)
treed666cdefbe6ac320827a2c6cb473581b46e22c4c /includes/Exception.php
parent183851b06bd6c52f3cae5375f433da720d410447 (diff)
Aktualisierung auf Version 1.8.1
Diffstat (limited to 'includes/Exception.php')
-rw-r--r--includes/Exception.php54
1 files changed, 39 insertions, 15 deletions
diff --git a/includes/Exception.php b/includes/Exception.php
index 1e24515b..56f18d5a 100644
--- a/includes/Exception.php
+++ b/includes/Exception.php
@@ -3,7 +3,8 @@
class MWException extends Exception
{
function useOutputPage() {
- return !empty( $GLOBALS['wgFullyInitialised'] );
+ return !empty( $GLOBALS['wgFullyInitialised'] ) &&
+ !empty( $GLOBALS['wgArticle'] ) && !empty( $GLOBALS['wgTitle'] );
}
function useMessageCache() {
@@ -19,16 +20,28 @@ class MWException extends Exception
return wfMsgReplaceArgs( $fallback, $args );
}
}
-
+
function getHTML() {
- return '<p>' . htmlspecialchars( $this->getMessage() ) .
- '</p><p>Backtrace:</p><p>' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ) .
- "</p>\n";
+ global $wgShowExceptionDetails;
+ if( $wgShowExceptionDetails ) {
+ return '<p>' . htmlspecialchars( $this->getMessage() ) .
+ '</p><p>Backtrace:</p><p>' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ) .
+ "</p>\n";
+ } else {
+ return "<p>Set <b><tt>\$wgShowExceptionDetails = true;</tt></b> " .
+ "in LocalSettings.php to show detailed debugging information.</p>";
+ }
}
function getText() {
- return $this->getMessage() .
- "\nBacktrace:\n" . $this->getTraceAsString() . "\n";
+ global $wgShowExceptionDetails;
+ if( $wgShowExceptionDetails ) {
+ return $this->getMessage() .
+ "\nBacktrace:\n" . $this->getTraceAsString() . "\n";
+ } else {
+ return "<p>Set <tt>\$wgShowExceptionDetails = true;</tt> " .
+ "in LocalSettings.php to show detailed debugging information.</p>";
+ }
}
function getPageTitle() {
@@ -40,6 +53,13 @@ class MWException extends Exception
}
}
+ function getLogMessage() {
+ $file = $this->getFile();
+ $line = $this->getLine();
+ $message = $this->getMessage();
+ return "{$_SERVER['REQUEST_URI']} Exception from line $line of $file: $message";
+ }
+
function reportHTML() {
global $wgOut;
if ( $this->useOutputPage() ) {
@@ -67,6 +87,10 @@ class MWException extends Exception
if ( $wgCommandLineMode ) {
$this->reportText();
} else {
+ $log = $this->getLogMessage();
+ if ( $log ) {
+ wfDebugLog( 'exception', $log );
+ }
$this->reportHTML();
}
}
@@ -93,11 +117,12 @@ class MWException extends Exception
function htmlFooter() {
echo "</body></html>";
- }
+ }
+
}
/**
- * Exception class which takes an HTML error message, and does not
+ * Exception class which takes an HTML error message, and does not
* produce a backtrace. Replacement for OutputPage::fatalError().
*/
class FatalError extends MWException {
@@ -145,11 +170,11 @@ function wfReportException( Exception $e ) {
$e->report();
} catch ( Exception $e2 ) {
// Exception occurred from within exception handler
- // Show a simpler error message for the original exception,
+ // Show a simpler error message for the original exception,
// don't try to invoke report()
$message = "MediaWiki internal error.\n\n" .
- "Original exception: " . $e->__toString() .
- "\n\nException caught inside exception handler: " .
+ "Original exception: " . $e->__toString() .
+ "\n\nException caught inside exception handler: " .
$e2->__toString() . "\n";
if ( !empty( $GLOBALS['wgCommandLineMode'] ) ) {
@@ -165,7 +190,7 @@ function wfReportException( Exception $e ) {
/**
* Exception handler which simulates the appropriate catch() handling:
- *
+ *
* try {
* ...
* } catch ( MWException $e ) {
@@ -181,8 +206,7 @@ function wfExceptionHandler( $e ) {
// Final cleanup, similar to wfErrorExit()
if ( $wgFullyInitialised ) {
try {
- wfProfileClose();
- logProfilingData(); // uses $wgRequest, hence the $wgFullyInitialised condition
+ wfLogProfilingData(); // uses $wgRequest, hence the $wgFullyInitialised condition
} catch ( Exception $e ) {}
}