changeset 488:fa890b814205

added some ExpatError debug log code imported from: moin--main--1.5--patch-492
author Thomas Waldmann <tw@waldmann-edv.de>
date Tue, 21 Mar 2006 16:40:32 +0000
parents 782c389db4e9
children 9082a95430db
files ChangeLog MoinMoin/converter/text_html_text_x_moin.py
diffstat 2 files changed, 24 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Mar 21 08:59:51 2006 +0000
+++ b/ChangeLog	Tue Mar 21 16:40:32 2006 +0000
@@ -2,6 +2,20 @@
 # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5
 #
 
+2006-03-21 17:40:32 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-492
+
+    Summary:
+      added some ExpatError debug log code
+    Revision:
+      moin--main--1.5--patch-492
+
+    added some ExpatError debug log code
+    
+
+    modified files:
+     ChangeLog MoinMoin/converter/text_html_text_x_moin.py
+
+
 2006-03-21 09:59:51 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-491
 
     Summary:
--- a/MoinMoin/converter/text_html_text_x_moin.py	Tue Mar 21 08:59:51 2006 +0000
+++ b/MoinMoin/converter/text_html_text_x_moin.py	Tue Mar 21 16:40:32 2006 +0000
@@ -5,7 +5,7 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import re
+import re, os
 import xml.dom.minidom
 from xml.dom import Node
 
@@ -1172,17 +1172,23 @@
             raise ConvertError("Strange image src: '%s'" % src)
 
 
-def parse(text):
+def parse(request, text):
     text = u'<?xml version="1.0"?>%s%s' % (dtd, text)
     text = text.encode(config.charset)
     try:
         return xml.dom.minidom.parseString(text)
     except xml.parsers.expat.ExpatError, msg:
-        raise ConvertError('ExpatError: %s' % msg)
+        # this sometimes crashes when it should not, so save the stuff to analyze it:
+        logname = os.path.join(request.cfg.data_dir, "expaterror.log")
+        f = file(logname, "w")
+        f.write(text)
+        f.write("\n" + "-"*80 + "\n" + msg)
+        f.close()
+        raise ConvertError('ExpatError: %s (see dump in %s)' % (msg, logname))
 
 def convert(request, pagename, text):
     text = u"<page>%s</page>" % text
-    tree = parse(text)
+    tree = parse(request, text)
     strip_whitespace().do(tree)
     return convert_tree(request, pagename).do(tree)