Question

reqUser =  friends.UserFriends.gql("where udid =:1", str(udid) ).get()
reqUserName = reqUser.userName

This is my code i want to know how to handle this error, this error comes at line 2

Était-ce utile?

La solution

you can use pythons try/except pair.

reqUser =  friends.UserFriends.gql("where udid =:1", str(udid) ).get()
try:
    reqUserName = reqUser.userName
except AttributeError:
    reqUserName = "No username found!"

this catches only AttributeError exceptions, so anything else will still be raised.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top