def exception_translated(exception_type):
 def _exception_translated(f):
  @functools.wraps(f)
  def wrapper(self, *args, **kwargs):
   try:
    return f(self, *args, **kwargs)
   except exception.PublicIDNotFound as e:
    if (exception_type == 'user'):
     raise exception.UserNotFound(user_id=str(e))
    elif (exception_type == 'group'):
     raise exception.GroupNotFound(group_id=str(e))
    elif (exception_type == 'assertion'):
     raise AssertionError(_('Invalid user / password'))
    else:
     raise
  return wrapper
 return _exception_translated

def exception_translated ( exception_type ) : def _exception_translated ( f ) : @ functools . wraps ( f ) def wrapper ( self , * args , ** kwargs ) : try : return f ( self , * args , ** kwargs ) except exception . PublicIDNotFound as e : if ( exception_type == 'user' ) : raise exception . UserNotFound ( user_id = str ( e ) ) elif ( exception_type == 'group' ) : raise exception . GroupNotFound ( group_id = str ( e ) ) elif ( exception_type == 'assertion' ) : raise AssertionError ( _ ( 'Invalid user / password' ) ) else : raise return wrapper return _exception_translated
wrap api calls to map to correct exception .