Browse code

Merge branch 'bug/proxy-exceptions' into upstream-master

Matt Domsch authored on 2015/02/04 11:01:31
Showing 1 changed files
... ...
@@ -59,7 +59,10 @@ class S3Error (S3Exception):
59 59
             except XmlParseError:
60 60
                 debug("Not an XML response")
61 61
             else:
62
-                self.info.update(self.parse_error_xml(tree))
62
+                try:
63
+                    self.info.update(self.parse_error_xml(tree))
64
+                except Exception, e:
65
+                    error("Error parsing xml: %s.  ErrorXML: %s" % (e, response["data"]))
63 66
 
64 67
         self.code = self.info["Code"]
65 68
         self.message = self.info["Message"]
... ...
@@ -98,11 +101,13 @@ class S3Error (S3Exception):
98 98
         error_node = tree
99 99
         if not error_node.tag == "Error":
100 100
             error_node = tree.find(".//Error")
101
-        for child in error_node.getchildren():
102
-            if child.text != "":
103
-                debug("ErrorXML: " + child.tag + ": " + repr(child.text))
104
-                info[child.tag] = child.text
105
-
101
+            if error_node is not None:
102
+                for child in error_node.getchildren():
103
+                    if child.text != "":
104
+                        debug("ErrorXML: " + child.tag + ": " + repr(child.text))
105
+                        info[child.tag] = child.text
106
+            else:
107
+                raise S3ResponseError("Malformed error XML returned from remote server.")
106 108
         return info
107 109
 
108 110