MediaWiki  1.29.2
ApiUsageException Class Reference

Exception used to abort API execution with an error. More...

Inheritance diagram for ApiUsageException:
Collaboration diagram for ApiUsageException:

Public Member Functions

 __construct (ApiBase $module=null, StatusValue $status, $httpCode=0)
 
 __toString ()
 
 getCodeString ()
 
 getMessageArray ()
 
 getMessageObject ()
 Return a Message object for this exception.
Returns
Message
More...
 
 getModulePath ()
 Fetch the responsible module name. More...
 
 getStatusValue ()
 Fetch the error status. More...
 
- Public Member Functions inherited from UsageException
 __construct ( $message, $codestr, $code=0, $extradata=null)
 
- Public Member Functions inherited from 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. 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=[])
 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 newWithMessage (ApiBase $module=null, $msg, $code=null, $data=null, $httpCode=0)
 
- Static Public Member Functions inherited from MWException
static isCommandLine ()
 Check whether we are in command line mode or not to report the exception in the correct format. More...
 

Protected Attributes

 $modulePath
 
 $status
 

Private Member Functions

 getApiMessage ()
 

Detailed Description

Exception used to abort API execution with an error.

If possible, use ApiBase::dieWithError() instead of throwing this directly.

Note
This currently extends UsageException for backwards compatibility, so all the existing code that catches UsageException won't break when stuff starts throwing ApiUsageException. Eventually UsageException will go away and this will (probably) extend MWException directly.

Definition at line 98 of file ApiUsageException.php.

Constructor & Destructor Documentation

◆ __construct()

ApiUsageException::__construct ( ApiBase  $module = null,
StatusValue  $status,
  $httpCode = 0 
)
Parameters
ApiBase | null$moduleAPI module responsible for the error, if known
StatusValue$statusStatus holding errors
int$httpCodeHTTP error code to use

Definition at line 108 of file ApiUsageException.php.

References $status, getApiMessage(), and ApiErrorFormatter\stripMarkup().

Member Function Documentation

◆ __toString()

ApiUsageException::__toString ( )
Returns
string

Reimplemented from UsageException.

Definition at line 214 of file ApiUsageException.php.

References getApiMessage(), and ApiErrorFormatter\stripMarkup().

◆ getApiMessage()

ApiUsageException::getApiMessage ( )
private
Returns
ApiMessage

Definition at line 151 of file ApiUsageException.php.

References ApiMessage\create().

Referenced by __construct(), __toString(), getCodeString(), and getMessageArray().

◆ getCodeString()

ApiUsageException::getCodeString ( )
Deprecated:
Do not use.

This only exists here because UsageException is in the inheritance chain for backwards compatibility.

Returns
string

Reimplemented from UsageException.

Definition at line 185 of file ApiUsageException.php.

References getApiMessage().

◆ getMessageArray()

ApiUsageException::getMessageArray ( )
Deprecated:
Do not use.

This only exists here because UsageException is in the inheritance chain for backwards compatibility.

Returns
array

Reimplemented from UsageException.

Definition at line 194 of file ApiUsageException.php.

References getApiMessage(), and ApiErrorFormatter\stripMarkup().

◆ getMessageObject()

ApiUsageException::getMessageObject ( )

Return a Message object for this exception.

Returns
Message

Implements ILocalizedException.

Definition at line 207 of file ApiUsageException.php.

◆ getModulePath()

ApiUsageException::getModulePath ( )

Fetch the responsible module name.

Returns
string|null

Definition at line 168 of file ApiUsageException.php.

References $modulePath.

◆ getStatusValue()

ApiUsageException::getStatusValue ( )

◆ newWithMessage()

static ApiUsageException::newWithMessage ( ApiBase  $module = null,
  $msg,
  $code = null,
  $data = null,
  $httpCode = 0 
)
static
Parameters
ApiBase | null$moduleAPI module responsible for the error, if known
string | array | Message$msgSee ApiMessage::create()
string | null$codeSee ApiMessage::create()
array | null$dataSee ApiMessage::create()
int$httpCodeHTTP error code to use
Returns
static

Definition at line 138 of file ApiUsageException.php.

References $code, ApiMessage\create(), and StatusValue\newFatal().

Referenced by ApiContinuationManager\__construct(), ApiBase\dieWithError(), WatchedItemQueryService\getWatchlistOwnerId(), and ApiBaseTest\provideGetParameterFromSettings().

Member Data Documentation

◆ $modulePath

ApiUsageException::$modulePath
protected

Definition at line 100 of file ApiUsageException.php.

Referenced by getModulePath().

◆ $status

ApiUsageException::$status
protected

Definition at line 101 of file ApiUsageException.php.

Referenced by __construct(), and getStatusValue().


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