@@ -146,17 +146,32 @@ def run_loop(self, request_cb, notification_cb,
146146 This should not be called from a plugin running in the host, which
147147 already runs the loop and dispatches events to plugins.
148148 """
149+ if err_cb is None :
150+ err_cb = sys .stderr .write
151+ self ._err_cb = err_cb
152+
149153 def filter_request_cb (name , args ):
154+ name = self ._from_nvim (name )
150155 args = walk (self ._from_nvim , args )
151- result = request_cb (self ._from_nvim (name ), args )
156+ try :
157+ result = request_cb (name , args )
158+ except Exception :
159+ msg = ("error caught in request handler '{} {}'\n {}\n \n "
160+ .format (name , args , format_exc_skip (1 , 5 )))
161+ self ._err_cb (msg )
162+ raise
152163 return walk (self ._to_nvim , result )
153164
154165 def filter_notification_cb (name , args ):
155- notification_cb (self ._from_nvim (name ), walk (self ._from_nvim , args ))
156-
157- if err_cb is None :
158- err_cb = sys .stderr .write
159- self ._err_cb = err_cb
166+ name = self ._from_nvim (name )
167+ args = walk (self ._from_nvim , args )
168+ try :
169+ notification_cb (name , args )
170+ except Exception :
171+ msg = ("error caught in notification handler '{} {}'\n {}\n \n "
172+ .format (name , args , format_exc_skip (1 , 5 )))
173+ self ._err_cb (msg )
174+ raise
160175
161176 self ._session .run (filter_request_cb , filter_notification_cb , setup_cb )
162177
0 commit comments