Skip to content

Commit 1f2a213

Browse files
sachinhreddy-sfdcGitHub Enterprise
authored andcommitted
Merge pull request #15 from embedded-service-for-web/u/sachin-hanumantha/W-16027372/invaliddeployment-error-bug
@W-16027372 - gracefully handle invalid deployment error bug
2 parents e01eb71 + 7718f9a commit 1f2a213

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

src/components/conversation.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ export default function Conversation(props) {
4040
conversationStatePromise
4141
.then(() => {
4242
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+
})
4447
});
4548

4649
return () => {
@@ -80,7 +83,13 @@ export default function Conversation(props) {
8083
return handleCreateNewConversation()
8184
.then(() => {
8285
console.log(`Completed initializing a new conversation with conversationId: ${getConversationId()}`);
86+
})
87+
.catch(err => {
88+
console.error(`${err}`);
8389
});
90+
})
91+
.catch(err => {
92+
console.error(`${err}`);
8493
});
8594
}
8695

@@ -99,8 +108,17 @@ export default function Conversation(props) {
99108
.then(() => {
100109
console.log(`Successfully listed the conversations.`);
101110
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}`);
103118
});
119+
})
120+
.catch(err => {
121+
console.error(`${err}`);
104122
});
105123
}
106124

@@ -135,6 +153,7 @@ export default function Conversation(props) {
135153
handleMessagingErrors(err);
136154
cleanupMessagingData();
137155
props.showMessagingWindow(false);
156+
throw new Error("Failed to fetch an Unauthenticated access token.");
138157
});
139158
}
140159

@@ -167,6 +186,7 @@ export default function Conversation(props) {
167186
handleMessagingErrors(err);
168187
cleanupMessagingData();
169188
props.showMessagingWindow(false);
189+
throw new Error("Failed to create a new conversation.");
170190
});
171191
}
172192

@@ -187,6 +207,7 @@ export default function Conversation(props) {
187207
.catch((err) => {
188208
console.error(`Something went wrong in fetching a Continuation Access Token: ${err && err.message ? err.message : err}`);
189209
handleMessagingErrors(err);
210+
throw new Error("Failed to fetch a Continuation access token.");
190211
});
191212
}
192213

@@ -220,6 +241,7 @@ export default function Conversation(props) {
220241
.catch((err) => {
221242
console.error(`Something went wrong in fetching a list of conversations: ${err && err.message ? err.message : err}`);
222243
handleMessagingErrors(err);
244+
throw new Error("Failed to list the conversations.");
223245
});
224246
}
225247

@@ -260,6 +282,7 @@ export default function Conversation(props) {
260282
.catch((err) => {
261283
console.error(`Something went wrong while processing entries from listConversationEntries response: ${err && err.message ? err.message : err}`);
262284
handleMessagingErrors(err);
285+
throw new Error("Failed to list the conversation entries for the current conversation.");
263286
});
264287
}
265288

@@ -285,6 +308,7 @@ export default function Conversation(props) {
285308
})
286309
.catch((err) => {
287310
handleMessagingErrors(err);
311+
throw new Error(err);
288312
});
289313
}
290314

@@ -704,6 +728,9 @@ export default function Conversation(props) {
704728
case 400:
705729
console.error(`Invalid request parameters. Please check your data before retrying: ${err.message}`);
706730
break;
731+
case 404:
732+
console.error(`Resource not found. Please check your data before retrying: ${err.message}`);
733+
break;
707734
case 429:
708735
console.warn(`Too many requests issued from the app. Try again in sometime: ${err.message}`);
709736
break;

0 commit comments

Comments
 (0)