import functools
import logging


def NoRaiseException(default_return_value=None, exception_message=''):
  """Returns decorator that catches and logs uncaught Exceptions.

  Args:
    default_return_value: Value to return in the case of uncaught Exception.
    exception_message: Message for uncaught exceptions.
  """
  def decorator(f):
    @functools.wraps(f)
    def wrapper(*args, **kwargs):
      try:
        return f(*args, **kwargs)
      except Exception:  # pylint: disable=broad-except
        logging.exception(exception_message)
        return default_return_value
    return wrapper
  return decorator