MediaWiki  master
MWExceptionRenderer Class Reference

Class to expose exceptions to the client (API bots, users, admins using CLI scripts) More...

Static Public Member Functions

static getHTML (Throwable $e)
 Format an HTML message for the given exception object. More...
 
static output (Throwable $e, $mode, Throwable $eNew=null)
 
static setShowExceptionDetails (bool $showDetails)
 
static shouldShowExceptionDetails ()
 

Public Attributes

const AS_PRETTY = 2
 
const AS_RAW = 1
 

Static Private Member Functions

static getCustomMessage (Throwable $e)
 Extract an additional user-visible message from an exception, or null if it has none. More...
 
static getExceptionTitle (Throwable $e)
 Get the page title to be used for a given exception. More...
 
static getShowBacktraceError (Throwable $e)
 
static getText (Throwable $e)
 
static header ( $header)
 
static isCommandLine ()
 
static msg ( $key, $fallback,... $params)
 Get a message from i18n. More...
 
static printError ( $message)
 Print a message, if possible to STDERR. More...
 
static reportHTML (Throwable $e)
 Output the throwable report using HTML. More...
 
static reportOutageHTML (Throwable $e)
 
static statusHeader ( $code)
 
static useOutputPage (Throwable $e)
 

Static Private Attributes

static $showExceptionDetails = false
 Whether to print exceptino details. More...
 

Detailed Description

Class to expose exceptions to the client (API bots, users, admins using CLI scripts)

Since
1.28

Definition at line 33 of file MWExceptionRenderer.php.

Member Function Documentation

◆ getCustomMessage()

static MWExceptionRenderer::getCustomMessage ( Throwable  $e)
staticprivate

Extract an additional user-visible message from an exception, or null if it has none.

Parameters
Throwable$e
Returns
string|null

Definition at line 313 of file MWExceptionRenderer.php.

References Message\newFromSpecifier(), and wfMessage().

◆ getExceptionTitle()

static MWExceptionRenderer::getExceptionTitle ( Throwable  $e)
staticprivate

Get the page title to be used for a given exception.

Parameters
Throwable$e
Returns
string

Definition at line 292 of file MWExceptionRenderer.php.

◆ getHTML()

static MWExceptionRenderer::getHTML ( Throwable  $e)
static

Format an HTML message for the given exception object.

Parameters
Throwable$e
Returns
string Html to output

Definition at line 208 of file MWExceptionRenderer.php.

References Html\errorBox(), MWExceptionHandler\getLogMessage(), MWExceptionHandler\getRedactedTraceAsString(), WebRequest\getRequestId(), and MWExceptionHandler\getURL().

Referenced by MediaWiki\run().

◆ getShowBacktraceError()

static MWExceptionRenderer::getShowBacktraceError ( Throwable  $e)
staticprivate
Parameters
Throwable$e
Returns
string

Definition at line 281 of file MWExceptionRenderer.php.

◆ getText()

static MWExceptionRenderer::getText ( Throwable  $e)
staticprivate
Parameters
Throwable$e
Returns
string

Definition at line 266 of file MWExceptionRenderer.php.

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

◆ header()

static MWExceptionRenderer::header (   $header)
staticprivate
Parameters
string$header

Definition at line 339 of file MWExceptionRenderer.php.

References $header.

◆ isCommandLine()

static MWExceptionRenderer::isCommandLine ( )
staticprivate
Returns
bool

Definition at line 332 of file MWExceptionRenderer.php.

◆ msg()

static MWExceptionRenderer::msg (   $key,
  $fallback,
  $params 
)
staticprivate

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 247 of file MWExceptionRenderer.php.

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

◆ output()

static MWExceptionRenderer::output ( Throwable  $e,
  $mode,
Throwable  $eNew = null 
)
static
Parameters
Throwable$eOriginal exception
int$modeMWExceptionExposer::AS_* constant
Throwable | null$eNewNew throwable from attempting to show the first

Definition at line 68 of file MWExceptionRenderer.php.

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

Referenced by MWExceptionHandler\report(), MWLBFactory\reportIfPrefixSet(), MWLBFactory\reportMismatchedDBs(), and MWLBFactory\reportMismatchedPrefixes().

◆ printError()

static MWExceptionRenderer::printError (   $message)
staticprivate

Print a message, if possible to STDERR.

Use this in command line mode only (see isCommandLine)

Parameters
string$messageFailure text

Definition at line 361 of file MWExceptionRenderer.php.

◆ reportHTML()

static MWExceptionRenderer::reportHTML ( Throwable  $e)
staticprivate

Output the throwable report using HTML.

Parameters
Throwable$e

Definition at line 171 of file MWExceptionRenderer.php.

References Html\element(), and RequestContext\getMain().

◆ reportOutageHTML()

static MWExceptionRenderer::reportOutageHTML ( Throwable  $e)
staticprivate
Parameters
Throwable$e

Definition at line 375 of file MWExceptionRenderer.php.

References Html\element().

◆ setShowExceptionDetails()

static MWExceptionRenderer::setShowExceptionDetails ( bool  $showDetails)
static
Parameters
bool$showDetails
Access: internal
For use by Setup.php and other internal use cases.

Definition at line 59 of file MWExceptionRenderer.php.

◆ shouldShowExceptionDetails()

static MWExceptionRenderer::shouldShowExceptionDetails ( )
static

◆ statusHeader()

static MWExceptionRenderer::statusHeader (   $code)
staticprivate
Parameters
int$code

Definition at line 348 of file MWExceptionRenderer.php.

References HttpStatus\header().

◆ useOutputPage()

static MWExceptionRenderer::useOutputPage ( Throwable  $e)
staticprivate
Parameters
Throwable$e
Returns
bool Should the throwable use $wgOut to output the error?

Definition at line 143 of file MWExceptionRenderer.php.

References RequestContext\getMain(), and getTitle().

Member Data Documentation

◆ $showExceptionDetails

MWExceptionRenderer::$showExceptionDetails = false
staticprivate

Whether to print exceptino details.

The default is configured by $wgShowExceptionDetails. May be changed at runtime via MWExceptionRenderer::setShowExceptionDetails().

See also
MainConfigNames::ShowExceptionDetails

Definition at line 45 of file MWExceptionRenderer.php.

◆ AS_PRETTY

◆ AS_RAW

const MWExceptionRenderer::AS_RAW = 1

Definition at line 34 of file MWExceptionRenderer.php.

Referenced by MWExceptionHandler\report().


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