Skip to content

Commit ca07d7f

Browse files
authored
Merge pull request aws#6984 from jguoamz/throttling
fix(chat): Send back throttling error message
2 parents 529da80 + 35ac939 commit ca07d7f

File tree

1 file changed

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

1 file changed

+15
-3
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,20 @@ export class Messenger {
742742
}
743743

744744
private showChatExceptionMessage(e: ChatException, tabID: string, requestID: string | undefined) {
745+
const title = 'An error occurred while processing your request.'
746+
// TODO: once the server sends the correct exception back, fix this
747+
if (e.statusCode && e.statusCode === '500') {
748+
// Send throttling message
749+
this.dispatcher.sendErrorMessage(
750+
new ErrorMessage(
751+
title,
752+
'We are experiencing heavy traffic, please try again shortly.'.trimEnd().trimStart(),
753+
tabID
754+
)
755+
)
756+
return
757+
}
758+
745759
let message = 'This error is reported to the team automatically. We will attempt to fix it as soon as possible.'
746760
if (e.errorMessage !== undefined) {
747761
message += `\n\nDetails: ${e.errorMessage}`
@@ -757,9 +771,7 @@ export class Messenger {
757771
message += `\n\nRequest ID: ${requestID}`
758772
}
759773

760-
this.dispatcher.sendErrorMessage(
761-
new ErrorMessage('An error occurred while processing your request.', message.trimEnd().trimStart(), tabID)
762-
)
774+
this.dispatcher.sendErrorMessage(new ErrorMessage(title, message.trimEnd().trimStart(), tabID))
763775
}
764776

765777
public sendOpenSettingsMessage(triggerId: string, tabID: string) {

0 commit comments

Comments
 (0)