You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/components/conversation.js
+29-2Lines changed: 29 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,10 @@ export default function Conversation(props) {
40
40
conversationStatePromise
41
41
.then(()=>{
42
42
handleSubscribeToEventSource()
43
-
.then(props.uiReady(true));// Let parent (i.e. MessagingWindow) know the app is UI ready so that the parent can decide to show the actual Messaging window UI.
43
+
.then(props.uiReady(true))// Let parent (i.e. MessagingWindow) know the app is UI ready so that the parent can decide to show the actual Messaging window UI.
44
+
.catch(()=>{
45
+
props.showMessagingWindow(false);
46
+
})
44
47
});
45
48
46
49
return()=>{
@@ -80,7 +83,13 @@ export default function Conversation(props) {
80
83
returnhandleCreateNewConversation()
81
84
.then(()=>{
82
85
console.log(`Completed initializing a new conversation with conversationId: ${getConversationId()}`);
86
+
})
87
+
.catch(err=>{
88
+
console.error(`${err}`);
83
89
});
90
+
})
91
+
.catch(err=>{
92
+
console.error(`${err}`);
84
93
});
85
94
}
86
95
@@ -99,8 +108,17 @@ export default function Conversation(props) {
99
108
.then(()=>{
100
109
console.log(`Successfully listed the conversations.`);
101
110
handleListConversationEntries()
102
-
.then(console.log(`Successfully retrieved entries for the current conversation: ${getConversationId()}`));
111
+
.then(console.log(`Successfully retrieved entries for the current conversation: ${getConversationId()}`))
112
+
.catch(err=>{
113
+
console.error(`${err}`);
114
+
});
115
+
})
116
+
.catch(err=>{
117
+
console.error(`${err}`);
103
118
});
119
+
})
120
+
.catch(err=>{
121
+
console.error(`${err}`);
104
122
});
105
123
}
106
124
@@ -135,6 +153,7 @@ export default function Conversation(props) {
135
153
handleMessagingErrors(err);
136
154
cleanupMessagingData();
137
155
props.showMessagingWindow(false);
156
+
thrownewError("Failed to fetch an Unauthenticated access token.");
138
157
});
139
158
}
140
159
@@ -167,6 +186,7 @@ export default function Conversation(props) {
167
186
handleMessagingErrors(err);
168
187
cleanupMessagingData();
169
188
props.showMessagingWindow(false);
189
+
thrownewError("Failed to create a new conversation.");
170
190
});
171
191
}
172
192
@@ -187,6 +207,7 @@ export default function Conversation(props) {
187
207
.catch((err)=>{
188
208
console.error(`Something went wrong in fetching a Continuation Access Token: ${err&&err.message ? err.message : err}`);
189
209
handleMessagingErrors(err);
210
+
thrownewError("Failed to fetch a Continuation access token.");
190
211
});
191
212
}
192
213
@@ -220,6 +241,7 @@ export default function Conversation(props) {
220
241
.catch((err)=>{
221
242
console.error(`Something went wrong in fetching a list of conversations: ${err&&err.message ? err.message : err}`);
222
243
handleMessagingErrors(err);
244
+
thrownewError("Failed to list the conversations.");
223
245
});
224
246
}
225
247
@@ -260,6 +282,7 @@ export default function Conversation(props) {
260
282
.catch((err)=>{
261
283
console.error(`Something went wrong while processing entries from listConversationEntries response: ${err&&err.message ? err.message : err}`);
262
284
handleMessagingErrors(err);
285
+
thrownewError("Failed to list the conversation entries for the current conversation.");
263
286
});
264
287
}
265
288
@@ -285,6 +308,7 @@ export default function Conversation(props) {
285
308
})
286
309
.catch((err)=>{
287
310
handleMessagingErrors(err);
311
+
thrownewError(err);
288
312
});
289
313
}
290
314
@@ -704,6 +728,9 @@ export default function Conversation(props) {
704
728
case400:
705
729
console.error(`Invalid request parameters. Please check your data before retrying: ${err.message}`);
706
730
break;
731
+
case404:
732
+
console.error(`Resource not found. Please check your data before retrying: ${err.message}`);
733
+
break;
707
734
case429:
708
735
console.warn(`Too many requests issued from the app. Try again in sometime: ${err.message}`);
0 commit comments