Skip to content

Commit

Permalink
formattedError (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
josStorer committed Jan 26, 2024
1 parent 35cb508 commit dc471ea
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/ConversationCard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,23 @@ function ConversationCard(props) {
)
break
default: {
let formattedError = msg.error
if (typeof msg.error === 'string' && msg.error.trimStart().startsWith('{'))
try {
formattedError = JSON.stringify(JSON.parse(msg.error), null, 2)
} catch (e) {
/* empty */
}

let lastItem
if (conversationItemData.length > 0)
lastItem = conversationItemData[conversationItemData.length - 1]
if (lastItem && (lastItem.content.includes('gpt-loading') || lastItem.type === 'error'))
updateAnswer(t(msg.error), false, 'error')
updateAnswer(t(formattedError), false, 'error')
else
setConversationItemData([
...conversationItemData,
new ConversationItemData('error', t(msg.error)),
new ConversationItemData('error', t(formattedError)),
])
break
}
Expand Down

0 comments on commit dc471ea

Please sign in to comment.