소스 검색

Add file name to VObject serialization errors

Unrud 8 년 전
부모
커밋
95380c5ce7
1개의 변경된 파일8개의 추가작업 그리고 4개의 파일을 삭제
  1. 8 4
      radicale/storage.py

+ 8 - 4
radicale/storage.py

@@ -358,7 +358,11 @@ class Item:
 
 
     def serialize(self):
     def serialize(self):
         if self._text is None:
         if self._text is None:
-            self._text = self.item.serialize()
+            try:
+                self._text = self.item.serialize()
+            except Exception as e:
+                raise RuntimeError("Failed to serialize item %r from %r: %s" %
+                                   (self.href, self.collection.path, e)) from e
         return self._text
         return self._text
 
 
     @property
     @property
@@ -1120,12 +1124,12 @@ class Collection(BaseCollection):
                 vobject_item = Item(self, href=href,
                 vobject_item = Item(self, href=href,
                                     text=btext.decode(self.encoding)).item
                                     text=btext.decode(self.encoding)).item
                 check_and_sanitize_item(vobject_item, uid=cuid)
                 check_and_sanitize_item(vobject_item, uid=cuid)
+                # Serialize the object again, to normalize the text
+                # representation. The storage may have been edited externally.
+                ctext = vobject_item.serialize()
             except Exception as e:
             except Exception as e:
                 raise RuntimeError("Failed to load item %r in %r: %s" %
                 raise RuntimeError("Failed to load item %r in %r: %s" %
                                    (href, self.path, e)) from e
                                    (href, self.path, e)) from e
-            # Serialize the object again, to normalize the text representation.
-            # The storage may have been edited externally.
-            ctext = vobject_item.serialize()
             cetag = get_etag(ctext)
             cetag = get_etag(ctext)
             cuid = get_uid_from_object(vobject_item)
             cuid = get_uid_from_object(vobject_item)
             try:
             try: