prayagverma / gdata-python-client

Automatically exported from code.google.com/p/gdata-python-client
1 stars 0 forks source link

AppsClient for Provisioning API has no exposed attributes for AppsForYourDomain exceptions #642

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
*What steps will reproduce the problem?*
1. Trigger an AppsForYourDomain error, e.g.:

apps_client = gdata.apps.client.AppsClient(domain=DOMAIN)
apps_client.ClientLogin(email=email, password=password, source='apps')
user_entry = apps_client.RetrieveUser("nonexistentuser")

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.6/gdata/apps/client.py", line 106, in RetrieveUser
    return self.GetEntry(uri, desired_class=gdata.apps.data.UserEntry)
  File "/usr/lib/pymodules/python2.6/gdata/client.py", line 652, in get_entry
    desired_class=desired_class, **kwargs)
  File "/usr/lib/pymodules/python2.6/gdata/client.py", line 319, in request
    RequestError)
gdata.client.RequestError: Server responded with: 400, <?xml version="1.0" 
encoding="UTF-8"?>
<AppsForYourDomainErrors>
  <error errorCode="1301" invalidInput="nonexistentuser" reason="EntityDoesNotExist" />
</AppsForYourDomainErrors>

*What is the expected output?*
An exception with relevant attributes exposed to the python library in some 
way, e.g.:

try:
  user_entry = apps_client.RetrieveUser("nonexistentuser")
except gdata.client.AppsForYourDomainException, e:
  print "Error %d, %s: %s" % (e.errorCode, e.reason, e.invalidInput)

*What version of the product are you using?*
2.0.17

*Please provide any additional information below.*
gdata.apps.service.AppsService contains an AppsForYourDomainException, however 
the relevant attributes are similarly hidden solely in the 'body' property of 
the exception:
gdata.apps.service.AppsForYourDomainException: {'status': 400, 'body': '<?xml 
version="1.0" encoding="UTF-8"?>\r\n<AppsForYourDomainErrors>\r\n  <error 
errorCode="1301" invalidInput="nonexistentuser" reason="EntityDoesNotExist" 
/>\r\n</AppsForYourDomainErrors>\r\n\r\n', 'reason': 'Bad Request'}

*Workaround*:

errxml = atom.core.parse(e.body)
errtype = errxml.tag
erratts = errxml.GetElements(tag='error')[0].attributes
print "Error %s, %s: %s" % (erratts['errorCode'], erratts['reason'], 
erratts['invalidInput'])

Original issue reported on code.google.com by jf...@yelp.com on 17 Oct 2012 at 12:47

GoogleCodeExporter commented 9 years ago
Thank you for the workaround!

Original comment by rie...@squishypuppy.com on 8 Feb 2013 at 1:52