45 if ( $status->
isOK() ) {
46 throw new InvalidArgumentException( __METHOD__ .
' requires a fatal Status' );
49 $this->modulePath = $module ? $module->
getModulePath() :
null;
50 $this->status = $status;
55 $enMsg->inLanguage(
'en' )->useDatabase(
false );
69 ?
ApiBase $module, $msg, $code =
null, $data =
null, $httpCode = 0, Throwable $previous =
null
73 StatusValue::newFatal( ApiMessage::create( $msg, $code, $data ) ),
83 $errors = $this->status->getErrorsByType(
'error' );
85 $errors = $this->status->getErrors();
88 $msg =
new ApiMessage(
'apierror-unknownerror-nocode',
'unknownerror' );
90 $msg = ApiMessage::create( $errors[0] );
100 return $this->modulePath;
108 return $this->status;
115 return Status::wrap( $this->status )->getMessage();
123 $enMsg->inLanguage(
'en' )->useDatabase(
false );
126 return get_class( $this ) .
": {$enMsg->getApiCode()}: {$text} "
127 .
"in {$this->getFile()}:{$this->getLine()}\n"
128 .
"Stack trace:\n{$this->getTraceAsString()}"
129 . $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 @newable.
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)
Stable to call.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
isOK()
Returns whether the operation completed.
Interface for MediaWiki-localized exceptions.