Replace deprecated MWException

Bug: T328220
Change-Id: Iaf4a9bb4aafc741395d5ccc5a42c6a72b5d42b99
This commit is contained in:
Daimona Eaytoy 2023-06-08 11:13:24 +00:00
parent 81f673bc6d
commit 52ac696e25

View file

@ -24,10 +24,10 @@ use FormatJson;
use Html; use Html;
use IContextSource; use IContextSource;
use MediaWiki\MediaWikiServices; use MediaWiki\MediaWikiServices;
use MWException;
use Parser; use Parser;
use ParserOptions; use ParserOptions;
use ParserOutput; use ParserOutput;
use RuntimeException;
use Sanitizer; use Sanitizer;
use Status; use Status;
use TextContent; use TextContent;
@ -126,7 +126,6 @@ class SyntaxHighlight extends ExtensionTagHandler {
* @param array $args * @param array $args
* @param Parser $parser * @param Parser $parser
* @return string * @return string
* @throws MWException
*/ */
public static function parserHookSource( $text, $args, $parser ) { public static function parserHookSource( $text, $args, $parser ) {
$parser->addTrackingCategory( 'syntaxhighlight-source-category' ); $parser->addTrackingCategory( 'syntaxhighlight-source-category' );
@ -146,7 +145,6 @@ class SyntaxHighlight extends ExtensionTagHandler {
* @param array $args * @param array $args
* @param ?Parser $parser * @param ?Parser $parser
* @return array * @return array
* @throws MWException
*/ */
private static function processContent( string $text, array $args, ?Parser $parser = null ): array { private static function processContent( string $text, array $args, ?Parser $parser = null ): array {
// Don't trim leading spaces away, just the linefeeds // Don't trim leading spaces away, just the linefeeds
@ -179,7 +177,6 @@ class SyntaxHighlight extends ExtensionTagHandler {
* @param array $args * @param array $args
* @param Parser $parser * @param Parser $parser
* @return string * @return string
* @throws MWException
*/ */
public static function parserHook( $text, $args, $parser ) { public static function parserHook( $text, $args, $parser ) {
// Replace strip markers (For e.g. {{#tag:syntaxhighlight|<nowiki>...}}) // Replace strip markers (For e.g. {{#tag:syntaxhighlight|<nowiki>...}})
@ -226,7 +223,7 @@ class SyntaxHighlight extends ExtensionTagHandler {
if ( preg_match( '/^<div class="?mw-highlight"?>(.*)<\/div>$/s', trim( $out ), $m ) ) { if ( preg_match( '/^<div class="?mw-highlight"?>(.*)<\/div>$/s', trim( $out ), $m ) ) {
$out = trim( $m[1] ); $out = trim( $m[1] );
} else { } else {
throw new MWException( 'Unexpected output from Pygments encountered' ); throw new RuntimeException( 'Unexpected output from Pygments encountered' );
} }
} }
return $out; return $out;