38 MediaWikiServices::getInstance()->getLanguageFactory()->
getLanguage(
'en' ),
57 'message' => $msg->getKey(),
58 'params' => $msg->getParams(),
59 'code' => $msg->getApiCode(),
71 'code' => $msg->getApiCode(),
72 'info' => $msg->text(),
73 ] + $msg->getApiData();
85 $ret = parent::formatException( $exception, $options );
86 return empty( $options[
'bc'] ) ? $ret : $ret[
'info'];
92 if ( $tag ===
'error' ) {
94 $existingError = $this->result->getResultData( [
'error' ] );
95 if ( !is_array( $existingError ) ||
96 !isset( $existingError[
'code'] ) || !isset( $existingError[
'info'] )
99 'code' => $msg->getApiCode(),
101 ] + $msg->getApiData();
102 $this->result->addValue(
null,
'error', $value,
106 if ( $modulePath ===
null ) {
107 $moduleName =
'unknown';
109 $i = strrpos( $modulePath,
'+' );
110 $moduleName = $i ===
false ? $modulePath : substr( $modulePath, $i + 1 );
115 $path = [ $tag, $moduleName ];
116 $oldWarning = $this->result->getResultData( [ $tag, $moduleName, $tag ] );
117 if ( $oldWarning !==
null ) {
118 $warnPos = strpos( $oldWarning, $value );
120 if ( $warnPos !==
false && ( $warnPos === 0 || $oldWarning[$warnPos - 1] ===
"\n" ) ) {
122 $warnPos += strlen( $value );
123 if ( strlen( $oldWarning ) <= $warnPos || $oldWarning[$warnPos] ===
"\n" ) {
128 $value =
"$oldWarning\n$value";
130 $this->result->addContentValue(
$path, $tag, $value,
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
This class represents the result of the API operations.
const NO_SIZE_CHECK
For addValue() and similar functions, do not check size while adding a value Don't use this unless yo...
const OVERRIDE
Override existing value in addValue(), setValue(), and similar functions.
const ADD_ON_TOP
For addValue(), setValue() and similar functions, if the value does not exist, add it as the first el...
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
getErrors()
Get the list of errors.
getErrorsByType( $type)
Returns a list of status messages of the given type.
isGood()
Returns whether the operation completed and didn't have any error or warnings.