MediaWiki REL1_37
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, 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
 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.
 
 getPageTitle ()
 Return the title of the page when reporting this error in a HTTP response.
 
 getText ()
 Get the text to display when reporting the error on the command line.
 
 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.
 
 reportHTML ()
 Output the exception report using HTML.
 
 useMessageCache ()
 Can the extension use the Message class/wfMessage to get i18n-ed messages?
 
 useOutputPage ()
 Should the exception use $wgOut to output the error?
 

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

 $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.

@newable

Definition at line 29 of file ApiUsageException.php.

Constructor & Destructor Documentation

◆ __construct()

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 42 of file ApiUsageException.php.

References getApiMessage(), ApiBase\getModulePath(), StatusValue\isOK(), and ApiErrorFormatter\stripMarkup().

Member Function Documentation

◆ __toString()

ApiUsageException::__toString ( )
Returns
string

Definition at line 121 of file ApiUsageException.php.

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

◆ getApiMessage()

ApiUsageException::getApiMessage ( )
private
Returns
ApiMessage

Definition at line 82 of file ApiUsageException.php.

Referenced by __construct(), and __toString().

◆ getMessageObject()

ApiUsageException::getMessageObject ( )

Return a Message object for this exception.

Returns
Message

Implements ILocalizedException.

Definition at line 114 of file ApiUsageException.php.

◆ getModulePath()

ApiUsageException::getModulePath ( )

Fetch the responsible module name.

Returns
string|null

Definition at line 99 of file ApiUsageException.php.

Referenced by ApiMain\substituteResultWithError().

◆ getStatusValue()

ApiUsageException::getStatusValue ( )

◆ newWithMessage()

static 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 | Message$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 68 of file ApiUsageException.php.

Member Data Documentation

◆ $modulePath

ApiUsageException::$modulePath
protected

Definition at line 31 of file ApiUsageException.php.

◆ $status

ApiUsageException::$status
protected

Definition at line 32 of file ApiUsageException.php.


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