wfDebugLog( 'resourceloader', __METHOD__ . ": minification failed: $exception" );
$this->hasErrors = true;
// Return exception as a comment
- $result = self::makeComment( $exception->__toString() );
+ $result = self::formatException( $exception );
}
wfProfileOut( __METHOD__ );
wfDebugLog( 'resourceloader', __METHOD__ . ": preloading module info failed: $e" );
$this->hasErrors = true;
// Add exception to the output as a comment
- $errors .= self::makeComment( $e->__toString() );
+ $errors .= self::formatException( $e );
}
wfProfileIn( __METHOD__ . '-getModifiedTime' );
wfDebugLog( 'resourceloader', __METHOD__ . ": calculating maximum modified time failed: $e" );
$this->hasErrors = true;
// Add exception to the output as a comment
- $errors .= self::makeComment( $e->__toString() );
+ $errors .= self::formatException( $e );
}
}
}
/**
- * Generate a CSS or JS comment block
+ * Generate a CSS or JS comment block. Only use this for public data,
+ * not error message details.
*
* @param $text string
* @return string
return "/*\n$encText\n*/\n";
}
+ /**
+ * Handle exception display
+ *
+ * @param Exception $e to be shown to the user
+ * @return string sanitized text that can be returned to the user
+ */
+ public static function formatException( $e ) {
+ global $wgShowExceptionDetails;
+
+ if ( $wgShowExceptionDetails ) {
+ return self::makeComment( $e->__toString() );
+ } else {
+ return self::makeComment( wfMessage( 'internalerror' )->text() );
+ }
+ }
+
/**
* Generates code for a response
*
wfDebugLog( 'resourceloader', __METHOD__ . ": pre-fetching blobs from MessageBlobStore failed: $e" );
$this->hasErrors = true;
// Add exception to the output as a comment
- $exceptions .= self::makeComment( $e->__toString() );
+ $exceptions .= self::formatException( $e );
}
} else {
$blobs = array();
wfDebugLog( 'resourceloader', __METHOD__ . ": generating module package failed: $e" );
$this->hasErrors = true;
// Add exception to the output as a comment
- $exceptions .= self::makeComment( $e->__toString() );
+ $exceptions .= self::formatException( $e );
// Register module as missing
$missing[] = $name;