Anonymous committed d2e43fd

Not raising exceptions in hooks

Comments (0)

Files changed (3)

+- not raising exceptions in hooks : December 5, 2007
 > Public Release 0.3 : December 5, 2007
 - setting many configs using batchset in dialogs : December 1, 2007


 from rope.contrib import codeassist, generate
 from ropemacs import refactor, lisputils, dialog
-from ropemacs.lisputils import lispfunction, interactive, prefixed, rawprefixed
+from ropemacs.lisputils import (lispfunction, interactive, prefixed,
+                                rawprefixed, lisphook)
 class RopeInterface(object):
         return ''.join(result)
-    @lispfunction
+    @lisphook
     def before_save_actions(self):
         if self.project is not None:
             resource = self._get_resource()
                 self.old_content = ''
-    @lispfunction
+    @lisphook
     def after_save_actions(self):
         if self.project is not None:
             libutils.report_change(self.project, lisp.buffer_file_name(),
             self.old_content = None
-    @lispfunction
+    @lisphook
     def register_local_keys(self):
         for key, callback in self.local_keys:
             lisp.local_set_key(self._key_sequence(key), callback)
-    @lispfunction
+    @lisphook
     def exiting_actions(self):
         if self.project is not None:


     func.interaction = ''
     return func
 def prefixed(func):
     func.interaction = 'p'
     return func
 def rawprefixed(func):
     func.interaction = 'P'
     return func
+def lisphook(func):
+    def newfunc(*args, **kwds):
+        try:
+            func(*args, **kwds)
+        except Exception, e:
+            message('Exception in ropemacs hook: %s' %
+                    (type(e).__name__ + str(e)))
+    newfunc.interaction = ''
+    return newfunc
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.