Frage

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

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top