Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if we could parse API answer and throw exception on error #14

Closed
wants to merge 2 commits into from

Conversation

agrrh
Copy link
Contributor

@agrrh agrrh commented Aug 8, 2017

No description provided.

namecheap.py Outdated
@@ -108,7 +108,11 @@ def _fetch_xml(self, payload, extra_payload = None):
print(r.text)
xml = fromstring(r.text)

if xml.attrib['Status'] == 'ERROR':
# Ensure that API response is in valid format, see: https://github.com/Bemmu/PyNamecheap/issues/8
if 'Status' not in xml.attrib:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe write this as:
if xml.get('Status') is None:

(the ElementTree doc says that .get() is preferable to .attrib[])

@agrrh agrrh closed this Aug 9, 2017
@agrrh
Copy link
Contributor Author

agrrh commented Aug 9, 2017

Prefer #15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants