Skip to content

Commit 672e95f

Browse files
authored
fix(amazonq): catch error for show document (#7112)
## Problem catch error for show document it should not crash the server ## Solution --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 1f5f215 commit 672e95f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

packages/amazonq/src/lsp/chat/messages.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,17 @@ export function registerMessageListeners(
295295
languageClient.onRequest<ShowDocumentParams, ShowDocumentResult>(
296296
ShowDocumentRequest.method,
297297
async (params: ShowDocumentParams): Promise<ShowDocumentParams | ResponseError<ShowDocumentResult>> => {
298-
const uri = vscode.Uri.parse(params.uri)
299-
const doc = await vscode.workspace.openTextDocument(uri)
300-
await vscode.window.showTextDocument(doc, { preview: false })
301-
return params
298+
try {
299+
const uri = vscode.Uri.parse(params.uri)
300+
const doc = await vscode.workspace.openTextDocument(uri)
301+
await vscode.window.showTextDocument(doc, { preview: false })
302+
return params
303+
} catch (e) {
304+
return new ResponseError(
305+
LSPErrorCodes.RequestFailed,
306+
`Failed to open document: ${(e as Error).message}`
307+
)
308+
}
302309
}
303310
)
304311

0 commit comments

Comments
 (0)