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

Was it helpful?

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top