Skip to content

Commit

Permalink
lsp: Fix client error handling (#2205)
Browse files Browse the repository at this point in the history
  • Loading branch information
fox0430 authored Nov 20, 2024
1 parent 4db7d62 commit fc38051
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. _#2205: https://github.com/fox0430/moe/pull/2205

Fixed
.....

- `#2205`_ lsp: Fix client error handling

12 changes: 8 additions & 4 deletions src/moepkg/lsp/jsonrpc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ proc read*(s: OutputStream): Future[JsonRpcResponseResult] {.async.} =
else:
return JsonRpcResponseResult.err fmt"Invalid jsonrpc: {$res}"

proc write(s: InputStream, req: string) {.async.} =
try:
await s.stream.write(req)
except:
# TODO: Add messages to error log.
discard

proc send(
s: InputStream,
frame: string): Future[Result[(), string]] {.async.} =
Expand All @@ -163,10 +170,7 @@ proc send(

debugLog(MessageType.write, req)

try:
asyncSpawn s.stream.write(req)
except CatchableError as e:
return Result[(), string].err e.msg
asyncSpawn s.write(req)

return Result[(), string].ok ()

Expand Down

0 comments on commit fc38051

Please sign in to comment.