Author: waldi Date: Thu Mar 13 11:22:25 2008 New Revision: 10829 Log: lib/kconfigeditor/kconfig/menu/file.py: Provide proper exception.
Modified: people/waldi/utils/kconfigeditor2/lib/kconfigeditor/kconfig/menu/file.py Modified: people/waldi/utils/kconfigeditor2/lib/kconfigeditor/kconfig/menu/file.py ============================================================================== --- people/waldi/utils/kconfigeditor2/lib/kconfigeditor/kconfig/menu/file.py (original) +++ people/waldi/utils/kconfigeditor2/lib/kconfigeditor/kconfig/menu/file.py Thu Mar 13 11:22:25 2008 @@ -1,5 +1,15 @@ import re +class ParseException(Exception): + filename = None + lineno = None + + def __init__(self, text): + self.text = text + + def __str__(self): + return "%s:%d: %s" % (self.filename, self.lineno, self.text) + class File(list): def __init__(self, filename): self.filename = filename @@ -41,8 +51,10 @@ else: try: stack.top().process_line(line) - except Exception, e: - raise Exception("Can't parse: '%s' (%d): %s" % (line, lineno, e)) + except ParseException, e: + e.filename = filename + e.lineno = lineno + raise lineno += 1 return stack.top().process_stop(lineno, 0) @@ -121,7 +133,7 @@ def process_line(self, text): match = self.split_re.match(text) if not match: - raise Exception, "Can't parse: '%s'" % text + raise ParseException("No match") rest = match.group('rest1') or match.group('rest2') getattr(self, "process_%s" % match.group('word'))(rest, match.group('ind')) @@ -224,7 +236,7 @@ self.entry.prompt = match.group('text1') or match.group('text2') text = match.group('expression') else: - raise Exception + raise ParseException("Can't find a prompt") _Expression(self, text) def process_bool(self, text, ind): _______________________________________________ Kernel-svn-changes mailing list Kernel-svn-changes@lists.alioth.debian.org http://lists.alioth.debian.org/mailman/listinfo/kernel-svn-changes