microsoft / vscode-languageserver-node

Language server protocol implementation for VSCode. This allows implementing language services in JS/TS running on node.js
MIT License
1.47k stars 325 forks source link

Expose JSON-RPC Error Code in communication with LSP Server #1533

Open soyrubio opened 2 months ago

soyrubio commented 2 months ago

Recently I stumbled upon an issue where I was unable to catch error codes from the LSP Server. If the client?.sendRequest fails, it returns an Error object. The Error here has the following interface:

interface Error {
    name: string;
    message: string;
    stack?: string;
}

Thus I am unable to catch any error code which I sent from the LSP server. If anyone knows a workaround for this I would be greatful, but nevertheless it could be a nice improvement to include the Error code in the interface.

dbaeumer commented 2 months ago

Which request are you sending to the server.

Usually all response errors are converted in lower layers and if it is a ResponseErrorLiteral the code will be preserve (see https://github.com/microsoft/vscode-languageserver-node/blob/dbaeumer/nutritious-vulture-turquoise/jsonrpc/src/common/connection.ts#L922)

Best would be you provide me with a GitHub repository I can clone with a minimal setup that demos what you are seeing.