Skip to content

Feature request: show stacktrace when eval produces an error #37

@daveyarwood

Description

@daveyarwood

When I evaluate a form that throws an error, e.g. (/ 1 0), I get the following error:

error caught while executing async callback:
NvimError(b'Vim:E5108: Error while calling lua chunk for luaeval(): ...bundle/acid.nvim//lua/acid/middlewares/clipboard.lua:17: Unexpected type',)
Traceback (most recent call last):
  File "/home/dave/.vim/bundle/acid.nvim/rplugin/python3/acid/__init__.py", line 38, in <lambda>
    nvim.async_call(lambda: handler_impl(msg, wc, key))
  File "/home/dave/.vim/bundle/acid.nvim/rplugin/python3/acid/__init__.py", line 21, in impl
    nvim.funcs.luaeval(lua_cmd, msg)
  File "/usr/local/lib/python3.5/dist-packages/pynvim/api/nvim.py", line 299, in call
    return self.request('nvim_call_function', name, args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pynvim/api/nvim.py", line 182, in request
    res = self._session.request(name, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pynvim/msgpack_rpc/session.py", line 102, in request
    raise self.error_wrapper(err)
pynvim.api.nvim.NvimError: b'Vim:E5108: Error while calling lua chunk for luaeval(): ...bundle/acid.nvim//lua/acid/middlewares/clipboard.lua:17: Unexpected type'

the call was requested at
  File "/usr/lib/python3.5/threading.py", line 882, in _bootstrap
    self._bootstrap_inner()
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "../../.vim/bundle/acid.nvim/rplugin/python3/acid/nrepl/__init__.py", line 68, in run
    callback(incoming, self, key)
  File "/home/dave/.vim/bundle/acid.nvim/rplugin/python3/acid/__init__.py", line 38, in handler
    nvim.async_call(lambda: handler_impl(msg, wc, key))

Then I see the following written to the virtualtext:

(/ 1 0) ;; => ^[[1;31mjava.lang.ArithmeticException^[[m: ^[[3mDivide by zero^[[m\n

Some ideas:

  • It might be nice to strip out the ANSI color codes in the virtualtext so that the message is easier to read.

  • It would be really great if the stacktrace were easily accessible somehow.

    • Maybe there could be an :AcidShowError command that I could run with my cursor over the line that produced the exception?
    • Simple idea: maybe there could be an :AcidShowLastError that would show you *e?
      • I tried running :call AcidInsertEval() and then evaluating *e, but that just inserted nil into my buffer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions