34 parent::__construct(
$result, Language::factory(
'en' ),
'none',
false );
50 'message' => $msg->getKey(),
51 'params' => $msg->getParams(),
52 'code' => $msg->getApiCode(),
54 ApiResult::setIndexedTagName( $error[
'params'],
'param' );
64 'code' => $msg->getApiCode(),
65 'info' => $msg->text(),
66 ] + $msg->getApiData();
78 $ret = parent::formatException( $exception, $options );
79 return empty( $options[
'bc'] ) ? $ret : $ret[
'info'];
85 if ( $tag ===
'error' ) {
87 $existingError = $this->result->getResultData( [
'error' ] );
88 if ( !is_array( $existingError ) ||
89 !isset( $existingError[
'code'] ) || !isset( $existingError[
'info'] )
92 'code' => $msg->getApiCode(),
94 ] + $msg->getApiData();
95 $this->result->addValue(
null,
'error', $value,
96 ApiResult::OVERRIDE | ApiResult::ADD_ON_TOP | ApiResult::NO_SIZE_CHECK );
99 if ( $modulePath ===
null ) {
100 $moduleName =
'unknown';
102 $i = strrpos( $modulePath,
'+' );
103 $moduleName = $i ===
false ? $modulePath : substr( $modulePath, $i + 1 );
108 $path = [ $tag, $moduleName ];
109 $oldWarning = $this->result->getResultData( [ $tag, $moduleName, $tag ] );
110 if ( $oldWarning !==
null ) {
111 $warnPos = strpos( $oldWarning, $value );
113 if ( $warnPos !==
false && ( $warnPos === 0 || $oldWarning[$warnPos - 1] ===
"\n" ) ) {
115 $warnPos += strlen( $value );
116 if ( strlen( $oldWarning ) <= $warnPos || $oldWarning[$warnPos] ===
"\n" ) {
121 $value =
"$oldWarning\n$value";
123 $this->result->addContentValue(
$path, $tag, $value,
124 ApiResult::OVERRIDE | ApiResult::ADD_ON_TOP | ApiResult::NO_SIZE_CHECK );
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
This class represents the result of the API operations.
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.