def intercept_errors(api_error, ignore_errors=None):
 def _decorator(func):
  '\n        Function decorator that intercepts exceptions and translates them into API-specific errors.\n        '
  @wraps(func)
  def _wrapped(*args, **kwargs):
   '\n            Wrapper that evaluates a function, intercepting exceptions and translating them into\n            API-specific errors.\n            '
   try:
    return func(*args, **kwargs)
   except Exception as ex:
    for ignored in (ignore_errors or []):
     if isinstance(ex, ignored):
      msg = u"A handled error occurred when calling '{func_name}' with arguments '{args}' and keyword arguments '{kwargs}': {exception}".format(func_name=func.func_name, args=args, kwargs=kwargs, exception=(ex.developer_message if hasattr(ex, 'developer_message') else repr(ex)))
      LOGGER.warning(msg)
      raise
    msg = u"An unexpected error occurred when calling '{func_name}' with arguments '{args}' and keyword arguments '{kwargs}': {exception}".format(func_name=func.func_name, args=args, kwargs=kwargs, exception=(ex.developer_message if hasattr(ex, 'developer_message') else repr(ex)))
    LOGGER.exception(msg)
    raise api_error(msg)
  return _wrapped
 return _decorator

def intercept_errors ( api_error , ignore_errors = None ) : def _decorator ( func ) : @ wraps ( func ) def _wrapped ( * args , ** kwargs ) : try : return func ( * args , ** kwargs ) except Exception as ex : for ignored in ( ignore_errors or [ ] ) : if isinstance ( ex , ignored ) : msg = u"A handled error occurred when calling '{func_name}' with arguments '{args}' and keyword arguments '{kwargs}': {exception}" . format ( func_name = func . func_name , args = args , kwargs = kwargs , exception = ( ex . developer_message if hasattr ( ex , 'developer_message' ) else repr ( ex ) ) ) LOGGER . warning ( msg ) raise msg = u"An unexpected error occurred when calling '{func_name}' with arguments '{args}' and keyword arguments '{kwargs}': {exception}" . format ( func_name = func . func_name , args = args , kwargs = kwargs , exception = ( ex . developer_message if hasattr ( ex , 'developer_message' ) else repr ( ex ) ) ) LOGGER . exception ( msg ) raise api_error ( msg ) return _wrapped return _decorator
function decorator that intercepts exceptions and translates them into api-specific errors .