Fully log exceptions within ResourceLoader (including traces)
Change-Id: Icb479c76cd855244429fe65b29667783dcca8f53
This commit is contained in:
parent
46f74ea958
commit
c28251a9fd
2 changed files with 23 additions and 9 deletions
|
|
@ -247,16 +247,9 @@ class MWException extends Exception {
|
||||||
* It will be either HTML or plain text based on isCommandLine().
|
* It will be either HTML or plain text based on isCommandLine().
|
||||||
*/
|
*/
|
||||||
function report() {
|
function report() {
|
||||||
global $wgLogExceptionBacktrace, $wgMimeType;
|
global $wgMimeType;
|
||||||
$log = $this->getLogMessage();
|
|
||||||
|
|
||||||
if ( $log ) {
|
$this->logException();
|
||||||
if ( $wgLogExceptionBacktrace ) {
|
|
||||||
wfDebugLog( 'exception', $log . "\n" . $this->getTraceAsString() . "\n" );
|
|
||||||
} else {
|
|
||||||
wfDebugLog( 'exception', $log );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( defined( 'MW_API' ) ) {
|
if ( defined( 'MW_API' ) ) {
|
||||||
// Unhandled API exception, we can't be sure that format printer is alive
|
// Unhandled API exception, we can't be sure that format printer is alive
|
||||||
|
|
@ -273,6 +266,22 @@ class MWException extends Exception {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log the error message to the exception log (if enabled)
|
||||||
|
*/
|
||||||
|
function logException() {
|
||||||
|
global $wgLogExceptionBacktrace;
|
||||||
|
|
||||||
|
$log = $this->getLogMessage();
|
||||||
|
if ( $log ) {
|
||||||
|
if ( $wgLogExceptionBacktrace ) {
|
||||||
|
wfDebugLog( 'exception', $log . "\n" . $this->getTraceAsString() . "\n" );
|
||||||
|
} else {
|
||||||
|
wfDebugLog( 'exception', $log );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether we are in command line mode or not to report the exception
|
* Check whether we are in command line mode or not to report the exception
|
||||||
* in the correct format.
|
* in the correct format.
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,7 @@ class ResourceLoader {
|
||||||
// Save filtered text to Memcached
|
// Save filtered text to Memcached
|
||||||
$cache->set( $key, $result );
|
$cache->set( $key, $result );
|
||||||
} catch ( Exception $exception ) {
|
} catch ( Exception $exception ) {
|
||||||
|
$exception->logException();
|
||||||
wfDebugLog( 'resourceloader', __METHOD__ . ": minification failed: $exception" );
|
wfDebugLog( 'resourceloader', __METHOD__ . ": minification failed: $exception" );
|
||||||
$this->hasErrors = true;
|
$this->hasErrors = true;
|
||||||
// Return exception as a comment
|
// Return exception as a comment
|
||||||
|
|
@ -474,6 +475,7 @@ class ResourceLoader {
|
||||||
try {
|
try {
|
||||||
$this->preloadModuleInfo( array_keys( $modules ), $context );
|
$this->preloadModuleInfo( array_keys( $modules ), $context );
|
||||||
} catch ( Exception $e ) {
|
} catch ( Exception $e ) {
|
||||||
|
$e->logException();
|
||||||
wfDebugLog( 'resourceloader', __METHOD__ . ": preloading module info failed: $e" );
|
wfDebugLog( 'resourceloader', __METHOD__ . ": preloading module info failed: $e" );
|
||||||
$this->hasErrors = true;
|
$this->hasErrors = true;
|
||||||
// Add exception to the output as a comment
|
// Add exception to the output as a comment
|
||||||
|
|
@ -493,6 +495,7 @@ class ResourceLoader {
|
||||||
// Calculate maximum modified time
|
// Calculate maximum modified time
|
||||||
$mtime = max( $mtime, $module->getModifiedTime( $context ) );
|
$mtime = max( $mtime, $module->getModifiedTime( $context ) );
|
||||||
} catch ( Exception $e ) {
|
} catch ( Exception $e ) {
|
||||||
|
$e->logException();
|
||||||
wfDebugLog( 'resourceloader', __METHOD__ . ": calculating maximum modified time failed: $e" );
|
wfDebugLog( 'resourceloader', __METHOD__ . ": calculating maximum modified time failed: $e" );
|
||||||
$this->hasErrors = true;
|
$this->hasErrors = true;
|
||||||
// Add exception to the output as a comment
|
// Add exception to the output as a comment
|
||||||
|
|
@ -727,6 +730,7 @@ class ResourceLoader {
|
||||||
try {
|
try {
|
||||||
$blobs = MessageBlobStore::get( $this, $modules, $context->getLanguage() );
|
$blobs = MessageBlobStore::get( $this, $modules, $context->getLanguage() );
|
||||||
} catch ( Exception $e ) {
|
} catch ( Exception $e ) {
|
||||||
|
$e->logException();
|
||||||
wfDebugLog( 'resourceloader', __METHOD__ . ": pre-fetching blobs from MessageBlobStore failed: $e" );
|
wfDebugLog( 'resourceloader', __METHOD__ . ": pre-fetching blobs from MessageBlobStore failed: $e" );
|
||||||
$this->hasErrors = true;
|
$this->hasErrors = true;
|
||||||
// Add exception to the output as a comment
|
// Add exception to the output as a comment
|
||||||
|
|
@ -834,6 +838,7 @@ class ResourceLoader {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch ( Exception $e ) {
|
} catch ( Exception $e ) {
|
||||||
|
$e->logException();
|
||||||
wfDebugLog( 'resourceloader', __METHOD__ . ": generating module package failed: $e" );
|
wfDebugLog( 'resourceloader', __METHOD__ . ": generating module package failed: $e" );
|
||||||
$this->hasErrors = true;
|
$this->hasErrors = true;
|
||||||
// Add exception to the output as a comment
|
// Add exception to the output as a comment
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue