0
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

Andrei
  • 55,890
  • 9
  • 87
  • 108
yasir
  • 137
  • 2
  • 14
  • You can't get the name of a user that doesn't exist, so don't try to do that? What you should do instead depends what you're trying to achieve, there's not enough information to be able to answer that. –  Sep 12 '12 at 09:45
  • reqUser is, for some reasons, of type `None`. A `None` type object does not have any attributes. This means, the statement in the first line returns a `None` object. – Alex Sep 12 '12 at 09:45

1 Answers1

0

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.

Inbar Rose
  • 41,843
  • 24
  • 85
  • 131