Skip to content

Commit 35ac939

Browse files
committed
fix(chat): Send back throttling error message
1 parent e9cfe3a commit 35ac939

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
@@ -754,6 +754,20 @@ export class Messenger {
754754
}
755755

756756
private showChatExceptionMessage(e: ChatException, tabID: string, requestID: string | undefined) {
757+
const title = 'An error occurred while processing your request.'
758+
// TODO: once the server sends the correct exception back, fix this
759+
if (e.statusCode && e.statusCode === '500') {
760+
// Send throttling message
761+
this.dispatcher.sendErrorMessage(
762+
new ErrorMessage(
763+
title,
764+
'We are experiencing heavy traffic, please try again shortly.'.trimEnd().trimStart(),
765+
tabID
766+
)
767+
)
768+
return
769+
}
770+
757771
let message = 'This error is reported to the team automatically. We will attempt to fix it as soon as possible.'
758772
if (e.errorMessage !== undefined) {
759773
message += `\n\nDetails: ${e.errorMessage}`
@@ -769,9 +783,7 @@ export class Messenger {
769783
message += `\n\nRequest ID: ${requestID}`
770784
}
771785

772-
this.dispatcher.sendErrorMessage(
773-
new ErrorMessage('An error occurred while processing your request.', message.trimEnd().trimStart(), tabID)
774-
)
786+
this.dispatcher.sendErrorMessage(new ErrorMessage(title, message.trimEnd().trimStart(), tabID))
775787
}
776788

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

0 commit comments

Comments
 (0)