def _unwrap(self, ret_fun, err_fun):
    """Iterate over the options in the choice type, and try to perform some
    action on them. If the action fails (returns None or raises either CoercionError
    or ValueError), then it goes on to the next type.
    Args:
       ret_fun: a function that takes a wrapped option value, and either returns a successful
           return value or fails.
       err_fun: a function that takes the unwrapped value of this choice, and generates
           an appropriate error.
    Returns: the return value from a successful invocation of ret_fun on one of the
       type options. If no invocation fails, then returns the value of invoking err_fun.
    """
    for opt in self.CHOICES:
      if isinstance(self._value, opt):
        return ret_fun(self._value)
      else:
        try:
          o = opt(self._value)
          ret = ret_fun(o)
          if ret:
            return ret
        except (self.CoercionError, ValueError):
          pass
    return err_fun(self._value)