MediaWiki master
MediaWiki\Api\ApiUsageException Class Reference

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

Inherits MWException, Stringable, and ILocalizedException.

Collaboration diagram for MediaWiki\Api\ApiUsageException:

Public Member Functions

 __construct (?ApiBase $module, StatusValue $status, $httpCode=0, ?Throwable $previous=null)
 
 __toString ()
 
 getMessageObject ()
 Return a Message object for this exception.
Returns
Message

 
 getModulePath ()
 Fetch the responsible module name.
 
 getStatusValue ()
 Fetch the error status.
 
- Public Member Functions inherited from MWException
 hasOverriddenHandler ()
 
 isLoggable ()
 Whether to log this exception in the exception debug log.
 
 msg ( $key, $fallback,... $params)
 Get a message from i18n.
 
 report ()
 Output a report about the exception and takes care of formatting.
 
 useMessageCache ()
 Can the extension use the Message class/wfMessage to get i18n-ed messages?
 

Static Public Member Functions

static newWithMessage (?ApiBase $module, $msg, $code=null, $data=null, $httpCode=0, ?Throwable $previous=null)
 
- 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.
 

Protected Attributes

string null $modulePath
 
StatusValue $status
 

Detailed Description

Exception used to abort API execution with an error.

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

Stability: newable

Definition at line 40 of file ApiUsageException.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Api\ApiUsageException::__construct ( ?ApiBase $module,
StatusValue $status,
$httpCode = 0,
?Throwable $previous = null )
Stability: stable
to call
Parameters
ApiBase | null$moduleAPI module responsible for the error, if known
StatusValue$statusStatus holding errors
int$httpCodeHTTP error code to use
Throwable | null$previousPrevious exception

Definition at line 54 of file ApiUsageException.php.

References MediaWiki\Api\ApiUsageException\$status, MediaWiki\Api\ApiBase\getModulePath(), StatusValue\isOK(), and MediaWiki\Api\ApiErrorFormatter\stripMarkup().

Member Function Documentation

◆ __toString()

MediaWiki\Api\ApiUsageException::__toString ( )
Returns
string

Definition at line 133 of file ApiUsageException.php.

References MediaWiki\Api\ApiErrorFormatter\stripMarkup().

◆ getMessageObject()

MediaWiki\Api\ApiUsageException::getMessageObject ( )

Return a Message object for this exception.

Returns
Message

Implements ILocalizedException.

Definition at line 126 of file ApiUsageException.php.

◆ getModulePath()

MediaWiki\Api\ApiUsageException::getModulePath ( )

Fetch the responsible module name.

Returns
string|null

Definition at line 111 of file ApiUsageException.php.

References MediaWiki\Api\ApiUsageException\$modulePath.

◆ getStatusValue()

MediaWiki\Api\ApiUsageException::getStatusValue ( )

◆ newWithMessage()

static MediaWiki\Api\ApiUsageException::newWithMessage ( ?ApiBase $module,
$msg,
$code = null,
$data = null,
$httpCode = 0,
?Throwable $previous = null )
static
Parameters
ApiBase | null$moduleAPI module responsible for the error, if known
string | array | MessageSpecifier$msgSee ApiMessage::create()
string | null$codeSee ApiMessage::create()
array | null$dataSee ApiMessage::create()
int$httpCodeHTTP error code to use
Throwable | null$previousPrevious exception
Returns
static

Definition at line 80 of file ApiUsageException.php.

References MediaWiki\Api\ApiMessage\create().

Referenced by MediaWiki\Api\ApiContinuationManager\__construct().

Member Data Documentation

◆ $modulePath

string null MediaWiki\Api\ApiUsageException::$modulePath
protected

Definition at line 43 of file ApiUsageException.php.

Referenced by MediaWiki\Api\ApiUsageException\getModulePath().

◆ $status

StatusValue MediaWiki\Api\ApiUsageException::$status
protected

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