/**
  * Actually add the warning or error to the result
  * @param string $tag 'warning' or 'error'
  * @param string $moduleName
  * @param ApiMessage|ApiRawMessage $msg
  */
 protected function addWarningOrError($tag, $moduleName, $msg)
 {
     $value = ['code' => $msg->getApiCode()];
     switch ($this->format) {
         case 'wikitext':
             $value += ['text' => $msg->text(), ApiResult::META_CONTENT => 'text'];
             break;
         case 'html':
             $value += ['html' => $msg->parse(), ApiResult::META_CONTENT => 'html'];
             break;
         case 'raw':
             $value += ['message' => $msg->getKey(), 'params' => $msg->getParams()];
             ApiResult::setIndexedTagName($value['params'], 'param');
             break;
         case 'none':
             break;
     }
     $value += $msg->getApiData();
     $path = [$tag . 's', $moduleName];
     $existing = $this->result->getResultData($path);
     if ($existing === null || !in_array($value, $existing)) {
         $flags = ApiResult::NO_SIZE_CHECK;
         if ($existing === null) {
             $flags |= ApiResult::ADD_ON_TOP;
         }
         $this->result->addValue($path, null, $value, $flags);
         $this->result->addIndexedTagName($path, $tag);
     }
 }