Skip to content
This repository was archived by the owner on Jun 30, 2023. It is now read-only.

Commit 018b496

Browse files
committed
msgpack_rpc_stream: attempt to provide some context for the error
1 parent 591e641 commit 018b496

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

nvim/msgpack_rpc_stream.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ MsgpackRpcStream.__index = MsgpackRpcStream
6464
function MsgpackRpcStream.new(stream)
6565
return setmetatable({
6666
_stream = stream,
67+
_previous_chunk = nil,
6768
_pack = mpack.Packer({
6869
ext = {
6970
[Buffer] = function(o) return 0, mpack.pack(o.id) end,
@@ -123,16 +124,19 @@ function MsgpackRpcStream:read_start(request_cb, notification_cb, eof_cb)
123124
local printable = hexdump(data:sub(oldpos, oldpos + 8 * 10))
124125

125126
print(string.format("Error deserialising msgpack data stream at pos %d:\n%s\n", oldpos, printable))
127+
print(string.format("... occurred after %s", self._previous_chunk))
126128
error(errmsg)
127129
end
128130
if type == 'request' or type == 'notification' then
131+
self._previous_chunk = string.format('%s<%s>', type, method_or_error)
129132
if type == 'request' then
130133
request_cb(method_or_error, args_or_result, Response.new(self,
131134
id_or_cb))
132135
else
133136
notification_cb(method_or_error, args_or_result)
134137
end
135138
elseif type == 'response' then
139+
self._previous_chunk = string.format('response<%s,%s>', id_or_cb, args_or_result)
136140
if method_or_error == mpack.NIL then
137141
method_or_error = nil
138142
else

0 commit comments

Comments
 (0)