|
4 | 4 | package software.aws.toolkits.jetbrains.services.amazonq.lsp.flareChat |
5 | 5 |
|
6 | 6 | import com.google.gson.Gson |
| 7 | +import com.google.gson.JsonObject |
7 | 8 | import com.intellij.openapi.components.Service |
8 | 9 | import com.intellij.openapi.components.service |
9 | 10 | import com.intellij.openapi.project.Project |
10 | 11 | import kotlinx.coroutines.CompletableDeferred |
11 | 12 | import kotlinx.coroutines.CoroutineScope |
12 | 13 | import kotlinx.coroutines.launch |
13 | 14 | import org.eclipse.lsp4j.ProgressParams |
| 15 | +import org.eclipse.lsp4j.jsonrpc.ResponseErrorException |
14 | 16 | import software.aws.toolkits.core.utils.getLogger |
15 | 17 | import software.aws.toolkits.core.utils.warn |
16 | 18 | import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager |
@@ -122,8 +124,13 @@ class ChatCommunicationManager(private val cs: CoroutineScope) { |
122 | 124 | token?.let { |
123 | 125 | removePartialChatMessage(it) |
124 | 126 | } |
| 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 | + |
125 | 132 | val errorTitle = "An error occurred while processing your request." |
126 | | - val errorMessage = "Details: ${exception.message}" |
| 133 | + errorMessage = errorMessage ?: "Details: ${exception.message}" |
127 | 134 | val errorParams = Gson().toJson(ErrorParams(tabId, null, errorMessage, errorTitle)).toString() |
128 | 135 | val isPartialResult = false |
129 | 136 | val uiMessage = """ |
|
0 commit comments