Skip to content

Commit b6d4754

Browse files
authored
Merge pull request aws#6988 from jguoamz/jsonParse
fix(chat): handle JSON.parse error gracefully
2 parents d0a6bc1 + 9d382e5 commit b6d4754

File tree

1 file changed

+3
-4
lines changed
  • packages/core/src/codewhispererChat/controllers/chat/messenger

1 file changed

+3
-4
lines changed

packages/core/src/codewhispererChat/controllers/chat/messenger/messenger.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,11 @@ export class Messenger {
261261
}
262262

263263
if (cwChatEvent.toolUseEvent?.stop) {
264-
toolUse.input = JSON.parse(toolUseInput)
265-
toolUse.toolUseId = cwChatEvent.toolUseEvent.toolUseId ?? ''
266-
toolUse.name = cwChatEvent.toolUseEvent.name ?? ''
267-
268264
let toolError = undefined
269265
try {
266+
toolUse.toolUseId = cwChatEvent.toolUseEvent.toolUseId ?? ''
267+
toolUse.name = cwChatEvent.toolUseEvent.name ?? ''
268+
toolUse.input = JSON.parse(toolUseInput)
270269
const availableToolsNames = (session.pairProgrammingModeOn ? tools : noWriteTools).map(
271270
(item) => item.toolSpecification?.name
272271
)

0 commit comments

Comments
 (0)