Re-raise the currently-handled TypeError with the field name added.
170508
def _ReraiseTypeErrorWithFieldName(message_name, field_name):
  """"""
  exc = sys.exc_info()[1]
  if len(exc.args) == 1 and type(exc) is TypeError:
    # simple TypeError; add field name to exception message
    exc = TypeError('%s for field %s.%s' % (str(exc), message_name, field_name))

  # re-raise possibly-amended exception with original traceback:
  six.reraise(type(exc), exc, sys.exc_info()[2])
1165397
def handle_type_error(fn):
    
    @wraps(fn)
    def handle_type_error_wrapper(*args, **kwargs):
        def any_match(string_list, obj):
            return filter(lambda x: x in obj, string_list)

        try:
            return fn(*args, **kwargs)
        except TypeError as e:
            message = e.__str__()
            str_list = [
                "takes exactly",
                "got an unexpected",
                "takes no argument",
            ]
            if fn.__name__ in message and any_match(str_list, message):
                raise HTTPError(400, message)

            raise  # This will cause 500: Internal server error

    return handle_type_error_wrapper
1126783
def get_field(self, field_name, args, kwargs):
        """"""
        try:
            obj, arg_used = super(FormatterWrapper, self).get_field(
                    field_name, args, kwargs)
        except (KeyError, IndexError, AttributeError):
            if not self.tolerant:
                raise

            obj = MissingField(field_name)
            arg_used = field_name

        return obj, arg_used
809164
public void addError(String field, String error) {
		Assert.notNull(field, "field must not be null");
		Assert.notNull(error, "field must not be null");

		addErrors(field, Collections.singletonList(error));

		addResultProperty(SUCCESS_PROPERTY, Boolean.FALSE);
	}
1058480
def set_renamed_input_fields(self, renamed_input_fields):
        
        if not (isinstance(renamed_input_fields, basestring) or
                isinstance(renamed_input_fields, ListType)):
            raise ValueError("renamed_input_fields must be a string or a list")
        self.renamed_input_fields = renamed_input_fields
        return self
725468
@SuppressWarnings("unchecked")
	public void addErrors(String field, List<String> errors) {
		Assert.notNull(field, "field must not be null");
		Assert.notNull(errors, "field must not be null");

		// do not overwrite existing errors
		Map<String, List<String>> errorMap = (Map<String, List<String>>) this.result
				.get(ERRORS_PROPERTY);
		if (errorMap == null) {
			errorMap = new HashMap<>();
			addResultProperty(ERRORS_PROPERTY, errorMap);
		}

		List<String> fieldErrors = errorMap.get(field);
		if (fieldErrors == null) {
			fieldErrors = new ArrayList<>();
			errorMap.put(field, fieldErrors);
		}
		fieldErrors.addAll(errors);

		addResultProperty(SUCCESS_PROPERTY, Boolean.FALSE);
	}
362937
def raise_use_case_error(use_case, error)
      name = error.class.name.split('::').last

      klass = define_use_case_error(use_case, name)
      wrapped = klass.new(error.message)
      wrapped.set_backtrace(error.backtrace)

      raise wrapped
    end
1029764
def update(self, **kwargs):
        '''  '''
        redis = type(self).get_redis()
        errors = ValidationErrors()

        for fieldname, field in self.proxy:
            if not field.fillable:
                continue

            given = kwargs.get(fieldname)

            if given is None:
                continue

            try:
                value = field.validate(kwargs.get(fieldname), redis)
            except BadField as e:
                errors.append(e)
                continue

            setattr(
                self,
                fieldname,
                value
            )

        if errors.has_errors():
            raise errors

        return self.save()
312016
def format_error(self, field_name, message, index=None):
        
        pointer = ['/data']

        if index is not None:
            pointer.append(str(index))

        relationship = isinstance(
            self.declared_fields.get(field_name), BaseRelationship,
        )
        if relationship:
            pointer.append('relationships')
        elif field_name != 'id':
            # JSONAPI identifier is a special field that exists above the attribute object.
            pointer.append('attributes')

        pointer.append(self.inflect(field_name))

        if relationship:
            pointer.append('data')

        return {
            'detail': message,
            'source': {
                'pointer': '/'.join(pointer),
            },
        }
738845
def add_parameter(self, field_name, param_name, param_value):
        
        try:
            self.fields[field_name]['params'][param_name] = param_value
        except Exception as ex:
            raise ScriptFieldsError("Error adding parameter %s with value %s :%s" % (param_name, param_value, ex))

        return self
117047
def used(self, fieldname):
        """"""
        if fieldname in self.unused:
            self.unused.remove(fieldname)
1170104
def set_field(self, name, value):
        """"""
        f = getattr(self, name, None)
        if isinstance(f, DataField):
            f.set(self, value)
        else:
            raise FieldError("No field named '%s'" % name)
959724
def future_raise(self, tp, value=None, tb=None):
        """"""
        if value is not None and isinstance(tp, Exception):
            raise TypeError("instance exception may not have a separate value")
        if value is not None:
            exc = tp(value)
        else:
            exc = tp
        if exc.__traceback__ is not tb:
            raise exc.with_traceback(tb)
        raise exc
947543
function setFieldError (error) {
    // set path properties for error
    this.setErrorPath(error)
    // get field from error path and missing property name
    var field = this.getErrorField(error)
    // get error message based on error and custom messages on model
    var message = this.getErrorMessage(error)
    // if field is found and not hidden then add error to field
    if (field && !field.hidden) {
        // clear value from field - setting to default or undefined
        field.value = field.default
        // set error message on field
        field.error = message
    }
    // if not specific field set general error on field
    else {
        this.errors.push(message)
    }
}
278780
def reraise(error):
    """"""
    if hasattr(error, "_type_"):
        six.reraise(type(error), error, error._traceback)
    raise error
1328317
def wrap(self, methodName, types, skip=2):
        

        def handler(fields):
            try:
                args = [
                    field if typ is str else
                    int(field or 0) if typ is int else
                    float(field or 0) if typ is float else
                    bool(int(field or 0))
                    for (typ, field) in zip(types, fields[skip:])]
                method(*args)
            except Exception:
                self.logger.exception(f'Error for {methodName}:')

        method = getattr(self.wrapper, methodName, None)
        return handler if method else lambda *args: None
724590
def change(obj, **changed_fields):
    
    obj_field_names = {
        field.name for field in obj._meta.fields
    } | {
        field.attname for field in obj._meta.fields
    } | {'pk'}

    for field_name, value in changed_fields.items():
        if field_name not in obj_field_names:
            raise ValueError("'{}' is an invalid field name".format(field_name))
        setattr(obj, field_name, value)
    return obj