File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
src/components/ConversationCard Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -170,15 +170,23 @@ function ConversationCard(props) {
170
170
)
171
171
break
172
172
default : {
173
+ let formattedError = msg . error
174
+ if ( typeof msg . error === 'string' && msg . error . trimStart ( ) . startsWith ( '{' ) )
175
+ try {
176
+ formattedError = JSON . stringify ( JSON . parse ( msg . error ) , null , 2 )
177
+ } catch ( e ) {
178
+ /* empty */
179
+ }
180
+
173
181
let lastItem
174
182
if ( conversationItemData . length > 0 )
175
183
lastItem = conversationItemData [ conversationItemData . length - 1 ]
176
184
if ( lastItem && ( lastItem . content . includes ( 'gpt-loading' ) || lastItem . type === 'error' ) )
177
- updateAnswer ( t ( msg . error ) , false , 'error' )
185
+ updateAnswer ( t ( formattedError ) , false , 'error' )
178
186
else
179
187
setConversationItemData ( [
180
188
...conversationItemData ,
181
- new ConversationItemData ( 'error' , t ( msg . error ) ) ,
189
+ new ConversationItemData ( 'error' , t ( formattedError ) ) ,
182
190
] )
183
191
break
184
192
}
You can’t perform that action at this time.
0 commit comments