def _coerce_exceptions(function):
 def wrapper(*args, **kwargs):
  try:
   return function(*args, **kwargs)
  except IOException as e:
   e.msg = force_unicode(e.msg, errors='replace')
   e.stack = force_unicode(e.stack, errors='replace')
   LOG.exception(('Exception in Hadoop FS call ' + function.__name__))
   if (e.clazz == HADOOP_ACCESSCONTROLEXCEPTION):
    raise PermissionDeniedException(e.msg, e)
   else:
    raise
 return wrapper

def _coerce_exceptions ( function ) : def wrapper ( * args , ** kwargs ) : try : return function ( * args , ** kwargs ) except IOException as e : e . msg = force_unicode ( e . msg , errors = 'replace' ) e . stack = force_unicode ( e . stack , errors = 'replace' ) LOG . exception ( ( 'Exception in Hadoop FS call ' + function . __name__ ) ) if ( e . clazz == HADOOP_ACCESSCONTROLEXCEPTION ) : raise PermissionDeniedException ( e . msg , e ) else : raise return wrapper
decorator that causes exceptions thrown by the decorated function to be coerced into generic exceptions from the hadoop .