mirror of
https://github.com/GAM-team/GAM.git
synced 2025-07-10 14:43:34 +00:00
Fix error handling for nonexistent users in data transfers (#367)
This commit is contained in:
@ -2041,7 +2041,7 @@ def convertToUserID(user):
|
||||
if user.find(u'@') == -1:
|
||||
user = u'%s@%s' % (user, GC_Values[GC_DOMAIN])
|
||||
try:
|
||||
return callGAPI(cd.users(), u'get', throw_reasons=[u'notFound'], userKey=user, fields=u'id')[u'id']
|
||||
return callGAPI(cd.users(), u'get', throw_reasons=[u'userNotFound', u'badRequest', u'forbidden'], userKey=user, fields=u'id')[u'id']
|
||||
except googleapiclient.errors.HttpError:
|
||||
print u'ERROR: no such user %s' % user
|
||||
sys.exit(3)
|
||||
@ -2049,7 +2049,7 @@ def convertToUserID(user):
|
||||
def convertUserIDtoEmail(uid):
|
||||
cd = buildGAPIObject(u'directory')
|
||||
try:
|
||||
return callGAPI(cd.users(), u'get', throw_reasons=[u'notFound'], userKey=uid, fields=u'primaryEmail')[u'primaryEmail']
|
||||
return callGAPI(cd.users(), u'get', throw_reasons=[u'userNotFound', u'badRequest', u'forbidden'], userKey=uid, fields=u'primaryEmail')[u'primaryEmail']
|
||||
except googleapiclient.errors.HttpError:
|
||||
return u'uid:{0}'.format(uid)
|
||||
|
||||
|
Reference in New Issue
Block a user