Skip to content

Commit

Permalink
Provide some more details on XML parser errors.
Browse files Browse the repository at this point in the history
git-svn-id: https://django-eve-proxy.googlecode.com/svn/trunk@12 eae4c5b0-1759-11de-b208-e5a9466b8568
  • Loading branch information
Greg Taylor committed Jul 14, 2009
1 parent 4368259 commit 01eafbc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions django-eve-proxy/eve_proxy/models.py
@@ -1,5 +1,6 @@
import httplib
import urllib
import xml
from datetime import datetime, timedelta
from xml.dom import minidom
from django.db import models
Expand Down Expand Up @@ -27,8 +28,14 @@ def cache_from_eve_api(self, cached_doc, url_path, params):
# Save the response (an XML document) to the CachedDocument.
cached_doc.body = response.read()

# Parse the response via minidom
dom = minidom.parseString(cached_doc.body)
try:
# Parse the response via minidom
dom = minidom.parseString(cached_doc.body)
except xml.parsers.expat.ExpatError:
print "XML Parser Error:"
print cached_doc.body
return

# Set the CachedDocument's time_retrieved and cached_until times based
# on the values in the XML response. This will be used in future
# requests to see if the CachedDocument can be retrieved directly or
Expand Down

0 comments on commit 01eafbc

Please sign in to comment.