48 throw new InvalidArgumentException( __METHOD__ .
' requires a fatal Status' );
51 $this->modulePath = $module ? $module->
getModulePath() :
null;
56 $enMsg = clone $this->getApiMessage();
57 $enMsg->inLanguage(
'en' )->useDatabase(
false );
71 ?
ApiBase $module, $msg, $code =
null, $data =
null, $httpCode = 0, Throwable $previous =
null
84 private function getApiMessage() {
85 $errors = $this->status->getErrorsByType(
'error' );
87 $errors = $this->status->getErrors();
90 $msg =
new ApiMessage(
'apierror-unknownerror-nocode',
'unknownerror' );
117 return Status::wrap( $this->status )->getMessage();
124 $enMsg = clone $this->getApiMessage();
125 $enMsg->inLanguage(
'en' )->useDatabase(
false );
128 return get_class( $this ) .
": {$enMsg->getApiCode()}: {$text} "
129 .
"in {$this->getFile()}:{$this->getLine()}\n"
130 .
"Stack trace:\n{$this->getTraceAsString()}"
131 . ( $this->getPrevious() ?
"\n\nNext {$this->getPrevious()}" :
"" );
This abstract class implements many basic API functions, and is the base of all API classes.
getModulePath()
Get the path to this module.
Extension of Message implementing IApiMessage.
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
Exception used to abort API execution with an error.
getModulePath()
Fetch the responsible module name.
getStatusValue()
Fetch the error status.
static newWithMessage(?ApiBase $module, $msg, $code=null, $data=null, $httpCode=0, Throwable $previous=null)
getMessageObject()
Return a Message object for this exception.Message
__construct(?ApiBase $module, StatusValue $status, $httpCode=0, Throwable $previous=null)
Generic operation result class Has warning/error list, boolean status and arbitrary value.
static newFatal( $message,... $parameters)
Factory function for fatal errors.
Interface for MediaWiki-localized exceptions.