code: def violations_defaulted(default):
      """Decorator to default function value when a :class:`ConstraintViolation` occurs.
  
      >>> @violations_defaulted("foobar")
      ... @constrained([lambda x: x > 0])
      ... def f(x): return x+1
      >>> f(1)
      2
      >>> f(0)
      'foobar'
  
      """
  
      def wrapper(f):
          @functions.wraps(f)
          def wrapped_f(*args, **kwargs):
              try:
                  return f(*args, **kwargs)
              except ConstraintViolation:
                  return default
  
          return wrapped_f
  
      return wrapper
  
file_path: optunity/optunity/constraints.py
imports: import functools
  from .None import functions
label_desc: Use image node_id 10 for calling a global function with example usage: violations_defaulted(default) and returns: wrapper, wrapped_f, f, default