Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4192731
LocalizedException.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
LocalizedException.php
View Options
<?php
/**
* @license GPL-2.0-or-later
* @file
*/
namespace
MediaWiki\Exception
;
use
Exception
;
use
MediaWiki\Message\Message
;
use
MediaWiki\Parser\Sanitizer
;
use
Throwable
;
use
Wikimedia\Message\MessageSpecifier
;
/**
* Basic localized exception.
*
* @newable
* @stable to extend
* @since 1.29
* @ingroup Exception
* @note Don't use this in a situation where MessageCache is not functional.
*/
class
LocalizedException
extends
Exception
implements
ILocalizedException
{
/** @var string|array|MessageSpecifier */
protected
$messageSpec
;
/**
* @stable to call
* @param string|array|MessageSpecifier $messageSpec See Message::newFromSpecifier
* @param int $code
* @param Throwable|null $previous The previous exception used for the exception
* chaining.
*/
public
function
__construct
(
$messageSpec
,
$code
=
0
,
?
Throwable
$previous
=
null
)
{
$this
->
messageSpec
=
$messageSpec
;
// Exception->getMessage() should be in plain English, not localized.
// So fetch the English version of the message, without local
// customizations, and make a basic attempt to turn markup into text.
$msg
=
$this
->
getMessageObject
()->
inLanguage
(
'en'
)->
useDatabase
(
false
)->
text
();
$msg
=
preg_replace
(
'!</?(var|kbd|samp|code)>!'
,
'"'
,
$msg
);
$msg
=
Sanitizer
::
stripAllTags
(
$msg
);
parent
::
__construct
(
$msg
,
$code
,
$previous
);
}
/** @inheritDoc */
public
function
getMessageObject
()
{
return
Message
::
newFromSpecifier
(
$this
->
messageSpec
);
}
}
/** @deprecated class alias since 1.44 */
class_alias
(
LocalizedException
::
class
,
'LocalizedException'
);
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 20 2026, 18:47 (14 w, 17 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
bd/25/a77722f720688e797ba09f24b0ef
Default Alt Text
LocalizedException.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment