Log exceptions

This commit is contained in:
Tim Starling 2006-08-02 17:40:09 +00:00
parent 9315e023dc
commit bcb9f9e1c0
2 changed files with 22 additions and 0 deletions

View file

@ -86,6 +86,11 @@ class DBConnectionError extends DBError {
return $this->getMessage() . "\n";
}
function getLogMessage() {
# Don't send to the exception log
return false;
}
function getPageTitle() {
global $wgSitename;
return "$wgSitename has a problem";
@ -205,6 +210,11 @@ class DBQueryError extends DBError {
}
}
function getLogMessage() {
# Don't send to the exception log
return false;
}
function getPageTitle() {
return $this->msg( 'databaseerror', 'Database error' );
}

View file

@ -41,6 +41,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() ) {
@ -68,6 +75,10 @@ class MWException extends Exception
if ( $wgCommandLineMode ) {
$this->reportText();
} else {
$log = $this->getLogMessage();
if ( $log ) {
wfDebugLog( 'exception', $log );
}
$this->reportHTML();
}
}
@ -95,6 +106,7 @@ class MWException extends Exception
function htmlFooter() {
echo "</body></html>";
}
}
/**