When trying to return a meaningful error about an unexpected data item
    we cannot just `repr(data)` as that could show a gigantic data struture.

    This utility should try to get the key of the first item or the single item
    in the data structure.
489730
def data_item(data):
    
    if isinstance(data, ndict):
        # OK, we have something that looks like {0: ('a', 'b')}
        # or something that is a regular dictionary
        # so try to return 'a' regardless of the length
        for item in data:
            return repr(data[item][0])
    elif isinstance(data, dict):
        for item in data:
            return repr(data[item])
    elif isinstance(data, list):
        return repr(data[0])
    return repr(data)
1100589
def get(self, key, failobj=None, exact=0):
        """"""
        if not exact:
            key = self.getfullkey(key,new=1)
        return self.data.get(key,failobj)
698103
def _error_repr(error):
    """"""
    error_repr = repr(error)
    if len(error_repr) > 200:
        error_repr = hash(type(error))
    return error_repr
590679
def check_key(data_object, key, cardinal=False):
    
    itype = (int, np.int32, np.int64)
    if not isinstance(key, itype + (slice, tuple, list, np.ndarray)):
        raise KeyError("Unknown key type {} for key {}".format(type(key), key))
    keys = data_object.index.values
    if cardinal and data_object._cardinal is not None:
        keys = data_object[data_object._cardinal[0]].unique()
    elif isinstance(key, itype) and key in keys:
        key = list(sorted(data_object.index.values[key]))
    elif isinstance(key, itype) and key < 0:
        key = list(sorted(data_object.index.values[key]))
    elif isinstance(key, itype):
        key = [key]
    elif isinstance(key, slice):
        key = list(sorted(data_object.index.values[key]))
    elif isinstance(key, (tuple, list, pd.Index)) and not np.all(k in keys for k in key):
        key = list(sorted(data_object.index.values[key]))
    return key
682861
def build_response_error(resposta = {})
      retorno = SuperpayApi::Retorno.new
      retorno.errors.add(:code, resposta.to_hash[:fault][:faultcode]) unless resposta.to_hash[:fault][:faultcode].blank?
      retorno.errors.add(:mensagem, resposta.to_hash[:fault][:faultstring]) unless resposta.to_hash[:fault][:faultstring].blank?
      return retorno
    end
794200
def _make_error(index, code, errmsg, operation):
    
    return {
        _UINDEX: index,
        _UCODE: code,
        _UERRMSG: errmsg,
        _UOP: operation
    }
313885
def then_the_return_element_have_no_key(context, line, key):
    
    line = int(line)
    data = context.apiRequest.data
    assert 0 <= line < len(data)
    assert key not in data[line]
1248576
def data_key(data) :
    ""
    if isinstance(data, (bytes, float, frozenset, int, str, tuple)) :
        result = data
    else :
        # data itself is non-hashable
        result = id(data)
    #end if
    return \
        result
1323454
def check_keys_split(self, decoded):
        
        bad_keys = set(decoded.keys()).difference(set(self._split_keys))
        if bad_keys:
            bad_keys = ", ".join(bad_keys)
            raise ValueError("JSON data had unexpected key(s): {bad_keys}"
                             .format(bad_keys=pprint_thing(bad_keys)))
1088120
function findErrorObj(data) {
  if (notObjectOrIsEmpty(data)) {
    return false;
  }
  // Only the attributes, not the data itself.
  for (let key in data) {
    let attr = data[key];
    const found = parseError.findErrorObj(attr);
    if (found) {
      return found;
    }
  }
  // Not found.
  return false;
}
77389
def GetDataAsObject(self):
    
    if not self._data:
      return None

    if self._data_type in self._STRING_VALUE_TYPES:
      try:
        return self._data.decode('utf-16-le')

      # AttributeError is raised when self._data has no decode method.
      except AttributeError as exception:
        raise errors.WinRegistryValueError((
            'Unsupported data type: {0!s} of value: {1!s} with error: '
            '{2!s}').format(type(self._data), self._name, exception))

      except UnicodeError as exception:
        raise errors.WinRegistryValueError(
            'Unable to decode data of value: {0!s} with error: {1!s}'.format(
                self._name, exception))

    elif (self._data_type == definitions.REG_DWORD and
          self._data_size == 4):
      return self._INT32_LITTLE_ENDIAN.MapByteStream(self._data)

    elif (self._data_type == definitions.REG_DWORD_BIG_ENDIAN and
          self._data_size == 4):
      return self._INT32_BIG_ENDIAN.MapByteStream(self._data)

    elif (self._data_type == definitions.REG_QWORD and
          self._data_size == 8):
      return self._INT64_LITTLE_ENDIAN.MapByteStream(self._data)

    elif self._data_type == definitions.REG_MULTI_SZ:
      try:
        utf16_string = self._data.decode('utf-16-le')
        # TODO: evaluate the use of filter here is appropriate behavior.
        return list(filter(None, utf16_string.split('\x00')))

      # AttributeError is raised when self._data has no decode method.
      except AttributeError as exception:
        raise errors.WinRegistryValueError((
            'Unsupported data type: {0!s} of value: {1!s} with error: '
            '{2!s}').format(type(self._data), self._name, exception))

      except UnicodeError as exception:
        raise errors.WinRegistryValueError(
            'Unable to read data from value: {0!s} with error: {1!s}'.format(
                self._name, exception))

    return self._data
1255803
def get_error(self, i=None, unit=None,
                  uncover=None, trail=None,
                  linebreak=None, sort_by_indep=None):
        
        return self.get_value(i=i, unit=unit,
                              uncover=uncover, trail=trail,
                              linebreak=linebreak, sort_by_indep=sort_by_indep,
                              attr='_error')
486877
def dottable_getitem(data, dottable_key, default=None):
    
    def getitem(value, *keys):
        if not keys:
            return default
        elif len(keys) == 1:
            key = keys[0]
            if isinstance(value, MutableMapping):
                return value.get(key, default)
            elif isinstance(value, Sequence) and \
                    not isinstance(value, six.string_types):
                return [getitem(v, key) for v in value]
            return default
        return getitem(getitem(value, keys[0]), *keys[1:])
    return getitem(data, *dottable_key.split('.'))
1154128
def _raise_error_from_response(data):
    """"""
    # Check the meta-data for why this request failed
    meta = data.get('meta')
    if meta:
        # Account for foursquare conflicts
        # see: https://developer.foursquare.com/overview/responses
        if meta.get('code') in (200, 409): return data
        exc = error_types.get(meta.get('errorType'))
        if exc:
            raise exc(meta.get('errorDetail'))
        else:
            _log_and_raise_exception('Unknown error. meta', meta)
    else:
        _log_and_raise_exception('Response format invalid, missing meta property. data', data)
1052795
def _get_error_message(response):
    """"""
    try:
        data = response.json()
        if "error_description" in data:
            return data['error_description']
        if "error" in data:
            return data['error']
    except Exception:
        pass

    return "Unknown error"
694565
def errReceived(self, data):
        
        lines = data.splitlines()
        for line in lines:
            log_error("*** {name} stderr *** {line}", 
                    name=self.name,
                    line=self.errFilter(line))
319351
function getError (type, expected, actual) {
        return {
            attribute: type,
            expected: expected,
            actual: actual,
            message: getMsg(type, expected)
        };
    }