Create a GraphQLError for an invalid return type.
15075
def invalid_return_type_error(
    return_type: GraphQLObjectType, result: Any, field_nodes: List[FieldNode]
) -> GraphQLError:
    """"""
    return GraphQLError(
        f"Expected value of type '{return_type.name}' but got: {inspect(result)}.",
        field_nodes,
    )
1358364
function createNonRecoverableUserError(
  message: string,
  locations?: ?$ReadOnlyArray<Location>,
  nodes?: ?$ReadOnlyArray<ASTNode>,
): NonRecoverableUserError {
  let messageWithLocations = message;
  if (locations != null) {
    const printedLocations = printLocations(locations);
    messageWithLocations =
      printedLocations.length === 0
        ? message
        : [message, ...printedLocations].join('\n\n') + '\n';
  }
  const error = new GraphQLError(messageWithLocations, nodes ?? []);
  return new Error(error.message);
}
692925
def _create_field_specification(schema_graph, graphql_types, field_type_overrides,
                                hidden_classes, cls_name):
    """"""
    def field_maker_func():
        """Create and return the fields for the given GraphQL type."""
        result = EXTENDED_META_FIELD_DEFINITIONS.copy()
        result.update(OrderedDict([
            (name, GraphQLField(value))
            for name, value in sorted(six.iteritems(_get_fields_for_class(
                schema_graph, graphql_types, field_type_overrides, hidden_classes, cls_name)),
                key=lambda x: x[0])
        ]))
        return result

    return field_maker_func
304209
function evalRequiredError(condition, required, type, name) {
    if (condition) {
        return new Error('Required argument <' + required + '> missing for ' + type + ': \'' + name + '\'');
    }
    return null;
}
56819
function createError (err, target) {
  return { status: 'error', target: target, message: err, timestamp: Date.now() }
}
12207
def _convert_errors(func):
    
    cast_Invalid = lambda e: Invalid(
        u"{message}, expected {expected}".format(
            message=e.message,
            expected=e.expected)
        if e.expected != u'-none-' else e.message,
        e.path,
        six.text_type(e))

    @wraps(func)
    def wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except good.SchemaError as e:
            raise SchemaError(six.text_type(e))
        except good.MultipleInvalid as ee:
            raise MultipleInvalid([cast_Invalid(e) for e in ee])
        except good.Invalid as e:
            # Since voluptuous throws MultipleInvalid almost always -- we follow the same pattern...
            raise MultipleInvalid([cast_Invalid(e)])
    return wrapper
312763
function _simulateGraphqlWrapping(originalError, locations, path, nodes, source, positions){
  var resultError = new Error();
  Object.defineProperties(resultError, {
    message: {
      value: originalError.message,
      // By being enumerable, JSON.stringify will include `message` in the
      // resulting output. This ensures that the simplist possible GraphQL
      // service adheres to the spec.
      enumerable: true,
      writable: true
    },
    locations: {
      // Coercing falsey values to undefined ensures they will not be included
      // in JSON.stringify() when not provided.
      value: locations || [
        {
          "line": 5,
          "column": 12,
          "field": "email" // HERE
        }
      ],
      // By being enumerable, JSON.stringify will include `locations` in the
      // resulting output. This ensures that the simplist possible GraphQL
      // service adheres to the spec.
      enumerable: true
    },
    path: {
      // Coercing falsey values to undefined ensures they will not be included
      // in JSON.stringify() when not provided.
      value: path || "Some path",
      // By being enumerable, JSON.stringify will include `path` in the
      // resulting output. This ensures that the simplist possible GraphQL
      // service adheres to the spec.
      enumerable: true
    },
    nodes: {
      value: nodes || 'Nodes'
    },
    source: {
      value: source || 'Source',
    },
    positions: {
      value: positions || 'Positions',
    },
    originalError: {
      value: originalError
    }
  });

  return resultError;
}
1139855
function createUserError(
  message: string,
  locations?: ?$ReadOnlyArray<Location>,
  nodes?: ?$ReadOnlyArray<ASTNode>,
): UserError {
  let messageWithLocations = message;
  if (locations != null) {
    const printedLocations = printLocations(locations);
    messageWithLocations =
      printedLocations.length === 0
        ? message
        : [message, ...printedLocations].join('\n\n') + '\n';
  }
  return new GraphQLError(messageWithLocations, nodes ?? []);
}
1327559
function (type, fn) {
  var result;
  try {
    result = fn();
  }
  catch (e) {
    result = {error: e};
  }

  if (result && !result.type && type)
    result.type = type;

  return result;
}
852040
function logQueryError (dbQueryId, options, err) {
    // require log client
    if (!this.logClient) {
        return
    }
    // do not log if query options flag is false
    if (options.log === false) {
        return
    }
    // log error
    this.logClient.log('dbResponse', {
        data: {
            code: err.code,
            isOperational: err.isOperational,
            message: err.message,
        },
        dbQueryId: dbQueryId.id,
        dbResponseSuccess: false,
        dbResponseCreateTime: microTimestamp(),
    })
}
344398
def _from_gerror(cls, error, own=True):
        """"""

        if not own:
            error = error.copy()

        self = cls()
        self._error = error
        return self
1216340
public static GraphqlErrorBuilder newError(DataFetchingEnvironment dataFetchingEnvironment) {
        return new GraphqlErrorBuilder()
                .location(dataFetchingEnvironment.getField().getSourceLocation())
                .path(dataFetchingEnvironment.getExecutionStepInfo().getPath());
    }
282952
def return_an_error(*args):
    '''
    '''
    list_errors = []
    list_errors.extend(list(args))

    errors = { 'errors': list_errors }
    return errors
605400
public void addError(GraphQLError error, ExecutionPath fieldPath) {
        //
        // see http://facebook.github.io/graphql/#sec-Errors-and-Non-Nullability about how per
        // field errors should be handled - ie only once per field if its already there for nullability
        // but unclear if its not that error path
        //
        for (GraphQLError graphQLError : errors) {
            List<Object> path = graphQLError.getPath();
            if (path != null) {
                if (fieldPath.equals(ExecutionPath.fromList(path))) {
                    return;
                }
            }
        }
        this.errors.add(error);
    }
1007424
function processInputObjectType(object: GraphQLInputObjectType) {
  return reduce(
    object._typeConfig,
    (def, value, key) => {
      return setDef(
        def,
        key,
        value,
        ['description', 'fields', 'astNode', 'onConflict'],
        object,
      );
    },
    { type: 'Input' },
    true,
  );
}
70772
def get_requests_with_errors(self):
        
        data = self._es.search(body={
            "size": max_query_results,
            "query": {
                "filtered": {
                    "query": {
                        "match_all": {}
                    },
                    "filter": {
                        "exists": {
                            "field": "errmsg"
                        }
                    }
                }
            }
        })
        return GremlinTestResult(False, data)
1066791
def _safe_match_argument(expected_type, argument_value):
    """"""
    if GraphQLString.is_same_type(expected_type):
        return _safe_match_string(argument_value)
    elif GraphQLID.is_same_type(expected_type):
        # IDs can be strings or numbers, but the GraphQL library coerces them to strings.
        # We will follow suit and treat them as strings.
        if not isinstance(argument_value, six.string_types):
            if isinstance(argument_value, bytes):  # should only happen in py3
                argument_value = argument_value.decode('utf-8')
            else:
                argument_value = six.text_type(argument_value)
        return _safe_match_string(argument_value)
    elif GraphQLFloat.is_same_type(expected_type):
        return represent_float_as_str(argument_value)
    elif GraphQLInt.is_same_type(expected_type):
        # Special case: in Python, isinstance(True, int) returns True.
        # Safeguard against this with an explicit check against bool type.
        if isinstance(argument_value, bool):
            raise GraphQLInvalidArgumentError(u'Attempting to represent a non-int as an int: '
                                              u'{}'.format(argument_value))
        return type_check_and_str(int, argument_value)
    elif GraphQLBoolean.is_same_type(expected_type):
        return type_check_and_str(bool, argument_value)
    elif GraphQLDecimal.is_same_type(expected_type):
        return _safe_match_decimal(argument_value)
    elif GraphQLDate.is_same_type(expected_type):
        return _safe_match_date_and_datetime(expected_type, (datetime.date,), argument_value)
    elif GraphQLDateTime.is_same_type(expected_type):
        return _safe_match_date_and_datetime(expected_type,
                                             (datetime.datetime, arrow.Arrow), argument_value)
    elif isinstance(expected_type, GraphQLList):
        return _safe_match_list(expected_type.of_type, argument_value)
    else:
        raise AssertionError(u'Could not safely represent the requested GraphQL type: '
                             u'{} {}'.format(expected_type, argument_value))