Example #1
0
 def _wrap_function(self, fn, sync, decode, nvim_bind, name, *args):
     if decode:
         args = walk(decode_if_bytes, args, decode)
     if nvim_bind is not None:
         args.insert(0, nvim_bind)
     try:
         return fn(*args)
     except Exception:
         if sync:
             msg = ("error caught in request handler '{} {}':\n{}".format(
                 name, args, format_exc_skip(1)))
             raise ErrorResponse(msg)
         else:
             msg = ("error caught in async handler '{} {}'\n{}\n".format(
                 name, args, format_exc_skip(1)))
             self._on_async_err(msg + "\n")
Example #2
0
 def python_execute(self, script, range_start, range_stop):
     """Handle the `python` ex command."""
     self._set_current_range(range_start, range_stop)
     try:
         exec(script, self.module.__dict__)
     except Exception:
         raise ErrorResponse(format_exc_skip(1))
Example #3
0
 def python_execute_file(self, file_path, range_start, range_stop):
     """Handle the `pyfile` ex command."""
     self._set_current_range(range_start, range_stop)
     with open(file_path, 'rb') as f:
         script = compile(f.read(), file_path, 'exec')
         try:
             exec(script, self.module.__dict__)
         except Exception:
             raise ErrorResponse(format_exc_skip(1))
Example #4
0
 def handler():
     try:
         fn(*args, **kwargs)
     except Exception as err:
         msg = ("error caught while executing async callback:\n"
                "{!r}\n{}\n \nthe call was requested at\n{}".format(
                    err, format_exc_skip(1), call_point))
         self._err_cb(msg)
         raise
Example #5
0
 def filter_notification_cb(name, args):
     name = self._from_nvim(name)
     args = walk(self._from_nvim, args)
     try:
         notification_cb(name, args)
     except Exception:
         msg = ("error caught in notification handler '{} {}'\n{}\n\n".
                format(name, args, format_exc_skip(1)))
         self._err_cb(msg)
         raise
Example #6
0
 def filter_request_cb(name, args):
     name = self._from_nvim(name)
     args = walk(self._from_nvim, args)
     try:
         result = request_cb(name, args)
     except Exception:
         msg = (
             "error caught in request handler '{} {}'\n{}\n\n".format(
                 name, args, format_exc_skip(1)))
         self._err_cb(msg)
         raise
     return walk(self._to_nvim, result)