MediaWiki
1.23.2
|
Handler class for MWExceptions. More...
Static Public Member Functions | |
static | getLogId (Exception $e) |
Get the ID for this error. More... | |
static | getLogMessage (Exception $e) |
Return the requested URL and point to file and line number from which the exception occurred. More... | |
static | getRedactedTrace (Exception $e) |
Return a copy of an exception's backtrace as an array. More... | |
static | getRedactedTraceAsString (Exception $e) |
Generate a string representation of an exception's stack trace. More... | |
static | getURL () |
If the exception occurred in the course of responding to a request, returns the requested URL. More... | |
static | handle ( $e) |
Exception handler which simulates the appropriate catch() handling: More... | |
static | installHandler () |
Install an exception handler for MediaWiki exception types. More... | |
static | jsonSerializeException (Exception $e, $pretty=false, $escaping=0) |
Serialize an Exception object to JSON. More... | |
static | logException (Exception $e) |
Log an exception to the exception log (if enabled). More... | |
static | printError ( $message) |
Print a message, if possible to STDERR. More... | |
static | rollbackMasterChangesAndLog (Exception $e) |
If there are any open database transactions, roll them back and log the stack trace of the exception that should have been caught so the transaction could be aborted properly. More... | |
Static Protected Member Functions | |
static | report (Exception $e) |
Report an exception to the user. More... | |
Handler class for MWExceptions.
Definition at line 25 of file MWExceptionHandler.php.
|
static |
Get the ID for this error.
The ID is saved so that one can match the one output to the user (when $wgShowExceptionDetails is set to false), to the entry in the debug log.
Exception | $e |
Definition at line 227 of file MWExceptionHandler.php.
References $e, and wfRandomString().
Referenced by MWException\getHTML(), MWException\getLogId(), and getLogMessage().
|
static |
Return the requested URL and point to file and line number from which the exception occurred.
Exception | $e |
Definition at line 257 of file MWExceptionHandler.php.
References $e, $file, $line, getLogId(), and getURL().
Referenced by MWException\getHTML(), MWException\getLogMessage(), MWException\getText(), logException(), report(), and rollbackMasterChangesAndLog().
|
static |
Return a copy of an exception's backtrace as an array.
Like Exception::getTrace, but replaces each element in each frame's argument array with the name of its class (if the element is an object) or its type (if the element is a PHP primitive).
Exception | $e |
Definition at line 206 of file MWExceptionHandler.php.
References $e.
Referenced by jsonSerializeException(), and MWExceptionHandlerTest\testGetRedactedTrace().
|
static |
Generate a string representation of an exception's stack trace.
Like Exception::getTraceAsString, but replaces argument values with argument type or class name.
Exception | $e |
Definition at line 163 of file MWExceptionHandler.php.
Referenced by MWException\getHTML(), MWException\getText(), and report().
|
static |
If the exception occurred in the course of responding to a request, returns the requested URL.
Otherwise, returns false.
Definition at line 241 of file MWExceptionHandler.php.
References global.
Referenced by getLogMessage(), and jsonSerializeException().
|
static |
Exception handler which simulates the appropriate catch() handling:
try { ... } catch ( MWException $e ) { $e->report(); } catch ( Exception $e ) { echo $e->__toString(); }
Definition at line 134 of file MWExceptionHandler.php.
References $e, $wgFullyInitialised, global, report(), rollbackMasterChangesAndLog(), and wfLogProfilingData().
Referenced by MediaWiki\run().
|
static |
Install an exception handler for MediaWiki exception types.
Definition at line 29 of file MWExceptionHandler.php.
References array().
|
static |
Serialize an Exception object to JSON.
The JSON object will have keys 'id', 'file', 'line', 'message', and 'url'. These keys map to string values, with the exception of 'line', which is a number, and 'url', which may be either a string URL or or null if the exception did not occur in the context of serving a web request.
If $wgLogExceptionBacktrace is true, it will also have a 'backtrace' key, mapped to the array return value of Exception::getTrace, but with each element in each frame's "args" array (if set) replaced with the argument's class name (if the argument is an object) or type name (if the argument is a PHP primitive).
Exception | $e | |
bool | $pretty | Add non-significant whitespace to improve readability (default: false). |
int | $escaping | Bitfield consisting of FormatJson::.*_OK class constants. |
Definition at line 318 of file MWExceptionHandler.php.
References $e, array(), FormatJson\encode(), getRedactedTrace(), getURL(), and global.
Referenced by logException(), MWExceptionTest\testJsonserializeexceptionBacktracingDisabled(), MWExceptionTest\testJsonserializeexceptionBacktracingEnabled(), MWExceptionTest\testJsonserializeexceptionKeys(), and MWExceptionTest\testJsonSerializeExceptions().
|
static |
Log an exception to the exception log (if enabled).
This method must not assume the exception is an MWException, it is also used to handle PHP errors or errors from other libraries.
Exception | $e |
Definition at line 351 of file MWExceptionHandler.php.
References $e, FormatJson\ALL_OK, getLogMessage(), global, jsonSerializeException(), and wfDebugLog().
Referenced by JobQueueFederated\doDelete(), JobQueueFederated\doGetSiblingQueueSizes(), JobQueueFederated\doGetSiblingQueuesWithJobs(), JobQueueFederated\doIsEmpty(), JobQueueFederated\doPop(), DeferredUpdates\doUpdates(), JobQueueFederated\doWaitForBackups(), SpecialRunJobs\executeJobs(), JobQueueGroup\executeReadyPeriodicTasks(), ResourceLoader\filter(), JobQueueFederated\getCrossPartitionSum(), ApiMain\handleException(), ResourceLoader\makeModuleResponse(), MWException\report(), and JobQueueFederated\tryJobInsertions().
|
static |
Print a message, if possible to STDERR.
Use this in command line mode only (see isCommandLine)
string | $message | Failure text |
Definition at line 93 of file MWExceptionHandler.php.
Referenced by report(), and MWException\report().
|
staticprotected |
Report an exception to the user.
Definition at line 36 of file MWExceptionHandler.php.
References $e, getLogMessage(), getRedactedTraceAsString(), global, MWException\isCommandLine(), and printError().
Referenced by handle().
|
static |
If there are any open database transactions, roll them back and log the stack trace of the exception that should have been caught so the transaction could be aborted properly.
Exception | $e |
Definition at line 111 of file MWExceptionHandler.php.
References $e, $factory, getLogMessage(), wfDebugLog(), and wfGetLBFactory().
Referenced by RunJobs\execute(), SpecialRunJobs\executeJobs(), handle(), ApiMain\handleException(), AssembleUploadChunksJob\run(), and PublishStashedFileJob\run().