summaryrefslogtreecommitdiff
path: root/includes/resourceloader/ResourceLoader.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/resourceloader/ResourceLoader.php')
-rw-r--r--includes/resourceloader/ResourceLoader.php26
1 files changed, 21 insertions, 5 deletions
diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php
index 27f682c2..4e047be4 100644
--- a/includes/resourceloader/ResourceLoader.php
+++ b/includes/resourceloader/ResourceLoader.php
@@ -175,7 +175,7 @@ class ResourceLoader {
$cache->set( $key, $result );
} catch ( Exception $exception ) {
// Return exception as a comment
- $result = $this->makeComment( $exception->__toString() );
+ $result = $this->formatException( $exception );
$this->hasErrors = true;
}
@@ -461,7 +461,7 @@ class ResourceLoader {
$this->preloadModuleInfo( array_keys( $modules ), $context );
} catch( Exception $e ) {
// Add exception to the output as a comment
- $errors .= $this->makeComment( $e->__toString() );
+ $errors .= $this->formatException( $e );
$this->hasErrors = true;
}
@@ -479,7 +479,7 @@ class ResourceLoader {
$mtime = max( $mtime, $module->getModifiedTime( $context ) );
} catch ( Exception $e ) {
// Add exception to the output as a comment
- $errors .= $this->makeComment( $e->__toString() );
+ $errors .= $this->formatException( $e );
$this->hasErrors = true;
}
}
@@ -663,6 +663,22 @@ class ResourceLoader {
}
/**
+ * Handle exception display
+ *
+ * @param Exception $e to be shown to the user
+ * @return string sanitized text that can be returned to the user
+ */
+ protected function formatException( $e ) {
+ global $wgShowExceptionDetails;
+
+ if ( $wgShowExceptionDetails ) {
+ return $this->makeComment( $e->__toString() );
+ } else {
+ return $this->makeComment( wfMessage( 'internalerror' )->text() );
+ }
+ }
+
+ /**
* Generates code for a response
*
* @param $context ResourceLoaderContext: Context in which to generate a response
@@ -686,7 +702,7 @@ class ResourceLoader {
$blobs = MessageBlobStore::get( $this, $modules, $context->getLanguage() );
} catch ( Exception $e ) {
// Add exception to the output as a comment
- $exceptions .= $this->makeComment( $e->__toString() );
+ $exceptions .= $this->formatException( $e );
$this->hasErrors = true;
}
} else {
@@ -792,7 +808,7 @@ class ResourceLoader {
}
} catch ( Exception $e ) {
// Add exception to the output as a comment
- $exceptions .= $this->makeComment( $e->__toString() );
+ $exceptions .= $this->formatException( $e );
$this->hasErrors = true;
// Register module as missing