MediaWiki  master
MWException Class Reference

MediaWiki exception. More...

Inheritance diagram for MWException:
Collaboration diagram for MWException:

Public Member Functions

 getHTML ()
 Format an HTML message for the current exception object. More...
 
 getPageTitle ()
 Return the title of the page when reporting this error in a HTTP response. More...
 
 getText ()
 Format plain text message for the current exception object. More...
 
 isLoggable ()
 Whether to log this exception in the exception debug log. More...
 
 msg ( $key, $fallback,... $params)
 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...
 
 useMessageCache ()
 Can the extension use the Message class/wfMessage to get i18n-ed messages? 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...
 

Private Member Functions

 useOutputPage ()
 Should the exception use $wgOut to output the error? More...
 
 writeToCommandLine ( $message)
 Write a message to stderr falling back to stdout if stderr unavailable. More...
 

Static Private Member Functions

static header ( $header)
 Send a header, if we haven't already sent them. More...
 
static statusHeader ( $code)
 

Detailed Description

MediaWiki exception.

Stability: newable
Stability: stable
to extend

Definition at line 29 of file MWException.php.

Member Function Documentation

◆ getHTML()

MWException::getHTML ( )

Format an HTML message for the current exception object.

Stability: stable
to override
Todo:
Rarely used, remove in favour of generic MWExceptionRenderer
Returns
string HTML to output

Reimplemented in HttpError, and FatalError.

Definition at line 110 of file MWException.php.

References $type, Html\errorBox(), MWExceptionHandler\getLogMessage(), MWExceptionHandler\getRedactedTraceAsString(), WebRequest\getRequestId(), MWExceptionHandler\getURL(), msg(), and MWExceptionRenderer\shouldShowExceptionDetails().

Referenced by reportHTML(), and wfStreamThumb().

◆ getPageTitle()

MWException::getPageTitle ( )

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

Stability: stable
to override
Returns
string

Definition at line 160 of file MWException.php.

References msg().

Referenced by reportHTML().

◆ getText()

MWException::getText ( )

Format plain text message for the current exception object.

Stability: stable
to override
Todo:
Rarely used, remove in favour of generic MWExceptionRenderer
Returns
string

Reimplemented in FatalError.

Definition at line 143 of file MWException.php.

References MWExceptionHandler\getLogMessage(), MWExceptionHandler\getRedactedTraceAsString(), and MWExceptionRenderer\shouldShowExceptionDetails().

Referenced by DatabaseInstaller\doUpgrade(), CreateAndPromote\execute(), PPFuzzTester\execute(), and report().

◆ header()

static MWException::header (   $header)
staticprivate

Send a header, if we haven't already sent them.

We shouldn't, but sometimes we might in a weird case like Export

Parameters
string$header

Definition at line 249 of file MWException.php.

References $header.

Referenced by HttpError\__construct(), HttpError\getHTML(), HttpError\report(), report(), and reportHTML().

◆ 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 240 of file MWException.php.

◆ isLoggable()

MWException::isLoggable ( )

Whether to log this exception in the exception debug log.

Stability: stable
to override
Since
1.23
Returns
bool

Reimplemented in HttpError.

Definition at line 53 of file MWException.php.

◆ msg()

MWException::msg (   $key,
  $fallback,
  $params 
)

Get a message from i18n.

Parameters
string$keyMessage name
string$fallbackDefault message if the message cache can't be called by the exception
mixed...$params To pass to wfMessage()
Returns
string Message with arguments replaced

Definition at line 82 of file MWException.php.

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

Referenced by ErrorPageError\__construct(), UploadChunkVerificationException\__construct(), UploadFromChunks\addChunk(), getHTML(), ErrorPageError\getMessageObject(), getPageTitle(), ErrorPageError\report(), UserNotLoggedIn\report(), reportHTML(), and UploadFromChunks\tryStashFile().

◆ 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().

Stability: stable
to override

Reimplemented in HttpError.

Definition at line 205 of file MWException.php.

References getText(), header(), reportHTML(), statusHeader(), and writeToCommandLine().

◆ reportHTML()

MWException::reportHTML ( )

Output the exception report using HTML.

Stability: stable
to override

Definition at line 168 of file MWException.php.

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

Referenced by report().

◆ statusHeader()

static MWException::statusHeader (   $code)
staticprivate

Definition at line 255 of file MWException.php.

References HttpStatus\header().

Referenced by report().

◆ useMessageCache()

MWException::useMessageCache ( )

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

Stability: stable
to override
Returns
bool

Definition at line 64 of file MWException.php.

Referenced by msg(), and useOutputPage().

◆ useOutputPage()

MWException::useOutputPage ( )
private

Should the exception use $wgOut to output the error?

Returns
bool

Definition at line 35 of file MWException.php.

References useMessageCache().

Referenced by reportHTML().

◆ writeToCommandLine()

MWException::writeToCommandLine (   $message)
private

Write a message to stderr falling back to stdout if stderr unavailable.

Parameters
string$message

Definition at line 225 of file MWException.php.

Referenced by report().


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