Project

General

Profile

« Previous | Next » 

Revision 1369

xml_func.py: process(): Also catch XML func internal errors to assist in debugging. Use new exc.add_exc_info() to save traceback in case later code throws exception, overwriting exc_info().

View differences:

xml_func.py
3 3
import datetime
4 4
import re
5 5
import sre_constants
6
import sys
6 7

  
7 8
import dates
8 9
import exc
......
30 31
    for child in xml_dom.NodeElemIter(node): process(child, on_error)
31 32
    name = node.tagName
32 33
    if name.startswith('_') and name in funcs:
33
        try: value = funcs[name](xml_dom.NodeTextEntryIter(node))
34
        except SyntaxException, e:
34
        try:
35
            value = funcs[name](xml_dom.NodeTextEntryIter(node))
36
            xml_dom.replace_with_text(node, value)
37
        except Exception, e: # also catch XML func internal errors
38
            # Save in case later code throws exception, overwriting exc_info()
39
            exc.add_exc_info(e)
35 40
            str_ = str(node)
36 41
            exc.add_msg(e, 'function:\n'+str_)
37 42
            xml_dom.replace(node, node.ownerDocument.createComment(
38 43
                '\n'+term.emph_multiline(str_).replace('--','-')))
39 44
                # comments can't contain '--'
40 45
            on_error(e)
41
        else: xml_dom.replace_with_text(node, value)
42 46

  
43 47
def map_items(func, items):
44 48
    return [(name, func(value)) for name, value in items]

Also available in: Unified diff