MediaWiki  1.23.2
MWException Class Reference

MediaWiki exception. More...

Inheritance diagram for MWException:
Collaboration diagram for MWException:

Public Member Functions

 getHTML ()
 If $wgShowExceptionDetails is true, return a HTML message with a backtrace to the error, otherwise show a message to ask to set it to true to show that information. More...
 
 getLogId ()
 Get a the ID for this error. More...
 
 getLogMessage ()
 Return the requested URL and point to file and line number from which the exception occurred. More...
 
 getPageTitle ()
 Return the title of the page when reporting this error in a HTTP response. More...
 
 getText ()
 Get the text to display when reporting the error on the command line. More...
 
 isLoggable ()
 Whether to log this exception in the exception debug log. More...
 
 msg ( $key, $fallback)
 Get a message from i18n. More...
 
 report ()
 Output a report about the exception and takes care of formatting. More...
 
 reportHTML ()
 Output the exception report using HTML. More...
 
 runHooks ( $name, $args=array())
 Run hook to allow extensions to modify the text of the exception. More...
 
 useMessageCache ()
 Can the extension use the Message class/wfMessage to get i18n-ed messages? More...
 
 useOutputPage ()
 Should the exception use $wgOut to output the error? More...
 

Static Public Member Functions

static isCommandLine ()
 Check whether we are in command line mode or not to report the exception in the correct format. More...
 

Detailed Description

MediaWiki exception.

Examples
/src/tests/phpunit/MediaWikiTestCase.php.

Definition at line 26 of file MWException.php.

Member Function Documentation

◆ getHTML()

MWException::getHTML ( )

If $wgShowExceptionDetails is true, return a HTML message with a backtrace to the error, otherwise show a message to ask to set it to true to show that information.

Returns
string html to output

Reimplemented in DBConnectionError, HttpError, DBExpectedError, and FatalError.

Definition at line 133 of file MWException.php.

References MWExceptionHandler\getLogId(), MWExceptionHandler\getLogMessage(), MWExceptionHandler\getRedactedTraceAsString(), and global.

Referenced by reportHTML().

◆ getLogId()

MWException::getLogId ( )

Get a the ID for this error.

Since
1.20
Deprecated:
since 1.22 Use MWExceptionHandler::getLogId instead.
Returns
string

Definition at line 186 of file MWException.php.

References MWExceptionHandler\getLogId(), and wfDeprecated().

◆ getLogMessage()

MWException::getLogMessage ( )

Return the requested URL and point to file and line number from which the exception occurred.

Since
1.8
Deprecated:
since 1.22 Use MWExceptionHandler::getLogMessage instead.
Returns
string

Definition at line 199 of file MWException.php.

References MWExceptionHandler\getLogMessage(), and wfDeprecated().

◆ getPageTitle()

MWException::getPageTitle ( )

Return the title of the page when reporting this error in a HTTP response.

Returns
string

Reimplemented in DBQueryError.

Definition at line 175 of file MWException.php.

References msg().

Referenced by reportHTML().

◆ getText()

MWException::getText ( )

Get the text to display when reporting the error on the command line.

If $wgShowExceptionDetails is true, return a text message with a backtrace to the error.

Returns
string

Reimplemented in DBExpectedError, and FatalError.

Definition at line 158 of file MWException.php.

References MWExceptionHandler\getLogMessage(), MWExceptionHandler\getRedactedTraceAsString(), and global.

Referenced by ChangePassword\execute(), CreateAndPromote\execute(), and report().

◆ isCommandLine()

static MWException::isCommandLine ( )
static

Check whether we are in command line mode or not to report the exception in the correct format.

Returns
bool

Definition at line 270 of file MWException.php.

References $GLOBALS.

Referenced by MWExceptionHandler\report().

◆ isLoggable()

MWException::isLoggable ( )

Whether to log this exception in the exception debug log.

Since
1.23
Returns
boolean

Reimplemented in DBQueryError, and DBConnectionError.

Definition at line 45 of file MWException.php.

◆ msg()

MWException::msg (   $key,
  $fallback 
)

Get a message from i18n.

Parameters
string$keymessage name
string$fallbackdefault message if the message cache can't be called by the exception The function also has other parameters that are arguments for the message
Returns
string message with arguments replaced

Reimplemented in DBConnectionError.

Definition at line 116 of file MWException.php.

References $args, $fallback, useMessageCache(), wfMessage(), and wfMsgReplaceArgs().

Referenced by ErrorPageError\__construct(), getPageTitle(), DBQueryError\getTextContent(), ErrorPageError\report(), and reportHTML().

◆ report()

MWException::report ( )

Output a report about the exception and takes care of formatting.

It will be either HTML or plain text based on isCommandLine().

Reimplemented in HttpError, ErrorPageError, PermissionsError, BadTitleError, and ThrottledError.

Definition at line 244 of file MWException.php.

References getText(), global, MWExceptionHandler\logException(), MWExceptionHandler\printError(), reportHTML(), and wfHttpError().

◆ reportHTML()

MWException::reportHTML ( )

Output the exception report using HTML.

Reimplemented in DBConnectionError.

Definition at line 207 of file MWException.php.

References $wgOut, getHTML(), getPageTitle(), global, msg(), runHooks(), and useOutputPage().

Referenced by report().

◆ runHooks()

MWException::runHooks (   $name,
  $args = array() 
)

Run hook to allow extensions to modify the text of the exception.

Parameters
string$nameclass name of the exception
array$argsarguments to pass to the callback functions
Returns
string|null string to output or null if any hook has been called

Definition at line 73 of file MWException.php.

References $args, $name, array(), as, and global.

Referenced by reportHTML().

◆ useMessageCache()

MWException::useMessageCache ( )

Can the extension use the Message class/wfMessage to get i18n-ed messages?

Returns
bool

Definition at line 54 of file MWException.php.

References $wgLang, as, and global.

Referenced by msg(), DBConnectionError\msg(), and useOutputPage().

◆ useOutputPage()

MWException::useOutputPage ( )

Should the exception use $wgOut to output the error?

Returns
bool

Reimplemented in DBConnectionError.

Definition at line 32 of file MWException.php.

References $GLOBALS, and useMessageCache().

Referenced by reportHTML().


The documentation for this class was generated from the following file: