diff --git a/src/tsp-client.ts b/src/tsp-client.ts index d466e385..27f41fc8 100644 --- a/src/tsp-client.ts +++ b/src/tsp-client.ts @@ -10,6 +10,7 @@ */ import { URI } from 'vscode-uri'; +import { ResponseError } from 'vscode-languageserver'; import type lsp from 'vscode-languageserver'; import type { CancellationToken } from 'vscode-jsonrpc'; import { Logger, PrefixingLogger } from './utils/logger.js'; @@ -302,13 +303,17 @@ export class TspClient { return this.executeAsync(CommandTypes.Geterr, args, token); } - public request( + public async request( command: K, args: StandardTsServerRequests[K][0], token?: CancellationToken, config?: ExecConfig, ): Promise> { - return this.execute(command, args, token, config); + try { + return await this.execute(command, args, token, config); + } catch (error) { + throw new ResponseError(1, (error as Error).message); + } } // Low-level API.