Commits

Henning Schröder committed 8ceee57

catch exception

  • Participants
  • Parent commits b28afde

Comments (0)

Files changed (1)

highlighter/__init__.py

 #from customhighlighter import CustomHighlighter as QSyntaxHighlighter
 
 class TextCharFormat(QTextCharFormat):
-    pass
+    NAME = QTextFormat.UserProperty + 1
 
 
 class Format(object):
 
-    __slots__ = ("NAME", "name", "tcf")
-
-    NAME = QTextFormat.UserProperty + 1
+    __slots__ = ("name", "tcf")
 
 
     def __init__(self, name, color=None, bold=None, italic=None, base_format=None):
                 tcf.setFontWeight(QFont.Normal)
         if italic is not None:
             tcf.setFontItalic(italic)
-        tcf.setProperty(Format.NAME, QVariant(name))
+        tcf.setProperty(TextCharFormat.NAME, QVariant(name))
         self.tcf = tcf
 
 
+class HighlighterError(Exception):
+    pass
+
 
 class Partition(object):
     # every partition maps to a specific state in QSyntaxHighlighter
         self.is_multiline = is_multiline
         try:
             self.search_end = re.compile(end, re.M|re.S).search
-        except Exception:
-            print name, end
-            raise
+        except Exception, exc:
+            raise HighlighterError("%s: %s %s" % (exc, name, end))
 
 
 
         try:
             self.search_start = re.compile(start_pat, re.M|re.S).search
         except Exception, exc:
-            print start_part
-            raise
+            raise HighlighterError("%s: %s" % (exc, start_pat))
 
+        
     def scan(self, current_state, text):
         last_pos = 0
         length = len(text)