original_string: protected function validate_add_field_result($result) {
  
          if (!$result) {
              throw new \moodle_exception('errorcreatingschema', 'search_solr', '', get_string('nodatafromserver', 'search_solr'));
          }
  
          $results = json_decode($result);
          if (!$results) {
              if (is_scalar($result)) {
                  $errormsg = $result;
              } else {
                  $errormsg = json_encode($result);
              }
              throw new \moodle_exception('errorcreatingschema', 'search_solr', '', $errormsg);
          }
  
          // It comes as error when fetching fields data.
          if (!empty($results->error)) {
              throw new \moodle_exception('errorcreatingschema', 'search_solr', '', $results->error);
          }
  
          // It comes as errors when adding fields.
          if (!empty($results->errors)) {
  
              // We treat this error separately.
              $errorstr = '';
              foreach ($results->errors as $error) {
                  $errorstr .= implode(', ', $error->errorMessages);
              }
              throw new \moodle_exception('errorcreatingschema', 'search_solr', '', $errorstr);
          }
  
      }
code: protected function validate_add_field_result($result) {
  
          if (!$result) {
              throw new \moodle_exception('errorcreatingschema', 'search_solr', '', get_string('nodatafromserver', 'search_solr'));
          }
  
          $results = json_decode($result);
          if (!$results) {
              if (is_scalar($result)) {
                  $errormsg = $result;
              } else {
                  $errormsg = json_encode($result);
              }
              throw new \moodle_exception('errorcreatingschema', 'search_solr', '', $errormsg);
          }
  
          // It comes as error when fetching fields data.
          if (!empty($results->error)) {
              throw new \moodle_exception('errorcreatingschema', 'search_solr', '', $results->error);
          }
  
          // It comes as errors when adding fields.
          if (!empty($results->errors)) {
  
              // We treat this error separately.
              $errorstr = '';
              foreach ($results->errors as $error) {
                  $errorstr .= implode(', ', $error->errorMessages);
              }
              throw new \moodle_exception('errorcreatingschema', 'search_solr', '', $errorstr);
          }
  
      }
code_tokens: protected function validate_add_field_result ( $ result ) { if ( ! $ result ) { throw new \ moodle_exception ( 'errorcreatingschema' , 'search_solr' , '' , get_string ( 'nodatafromserver' , 'search_solr' ) ) ; } $ results = json_decode ( $ result ) ; if ( ! $ results ) { if ( is_scalar ( $ result ) ) { $ errormsg = $ result ; } else { $ errormsg = json_encode ( $ result ) ; } throw new \ moodle_exception ( 'errorcreatingschema' , 'search_solr' , '' , $ errormsg ) ; } // It comes as error when fetching fields data. if ( ! empty ( $ results -> error ) ) { throw new \ moodle_exception ( 'errorcreatingschema' , 'search_solr' , '' , $ results -> error ) ; } // It comes as errors when adding fields. if ( ! empty ( $ results -> errors ) ) { // We treat this error separately. $ errorstr = '' ; foreach ( $ results -> errors as $ error ) { $ errorstr .= implode ( ', ' , $ error -> errorMessages ) ; } throw new \ moodle_exception ( 'errorcreatingschema' , 'search_solr' , '' , $ errorstr ) ; } }
docstring: Checks that the field results do not contain errors.
  
  @throws \moodle_exception
  @param string $results curl response body
  @return void
docstring_tokens: Checks that the field results do not contain errors .