Skip to content

Commit 722373a

Browse files
committed
fix(amazonq): include failure context in chat failure message
1 parent e260f78 commit 722373a

File tree

2 files changed

+9
-2
lines changed
  • plugins/amazonq

2 files changed

+9
-2
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/BrowserConnector.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ class BrowserConnector(
479479
} catch (_: CancellationException) {
480480
LOG.warn { "Cancelled chat generation" }
481481
} catch (e: Exception) {
482-
LOG.error(e) { "Failed to send chat message" }
482+
LOG.warn(e) { "Failed to send chat message" }
483483
browser.postChat(chatCommunicationManager.getErrorUiMessage(tabId, e, partialResultToken))
484484
}
485485
}

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/flareChat/ChatCommunicationManager.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
package software.aws.toolkits.jetbrains.services.amazonq.lsp.flareChat
55

66
import com.google.gson.Gson
7+
import com.google.gson.JsonObject
78
import com.intellij.openapi.components.Service
89
import com.intellij.openapi.components.service
910
import com.intellij.openapi.project.Project
1011
import kotlinx.coroutines.CompletableDeferred
1112
import kotlinx.coroutines.CoroutineScope
1213
import kotlinx.coroutines.launch
1314
import org.eclipse.lsp4j.ProgressParams
15+
import org.eclipse.lsp4j.jsonrpc.ResponseErrorException
1416
import software.aws.toolkits.core.utils.getLogger
1517
import software.aws.toolkits.core.utils.warn
1618
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager
@@ -122,8 +124,13 @@ class ChatCommunicationManager(private val cs: CoroutineScope) {
122124
token?.let {
123125
removePartialChatMessage(it)
124126
}
127+
var errorMessage: String? = null
128+
if (exception is ResponseErrorException) {
129+
errorMessage = (exception.responseError.data as? JsonObject)?.get("body")?.asString ?: exception.responseError.message
130+
}
131+
125132
val errorTitle = "An error occurred while processing your request."
126-
val errorMessage = "Details: ${exception.message}"
133+
errorMessage = errorMessage ?: "Details: ${exception.message}"
127134
val errorParams = Gson().toJson(ErrorParams(tabId, null, errorMessage, errorTitle)).toString()
128135
val isPartialResult = false
129136
val uiMessage = """

0 commit comments

Comments
 (0)