Skip to content

Commit 1c89a6e

Browse files
committed
Addressing comments
1 parent 0bab6b6 commit 1c89a6e

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/CodeWhispererUTGChatManager.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import software.aws.toolkits.jetbrains.services.amazonqCodeTest.session.Session
3939
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.utils.combineBuildAndExecuteLogFiles
4040
import software.aws.toolkits.jetbrains.services.codemodernizer.utils.calculateTotalLatency
4141
import software.aws.toolkits.jetbrains.services.codewhisperer.codetest.CodeTestException
42-
import software.aws.toolkits.jetbrains.services.codewhisperer.codetest.codeTestServerException
4342
import software.aws.toolkits.jetbrains.services.codewhisperer.codetest.sessionconfig.CodeTestSessionConfig
4443
import software.aws.toolkits.jetbrains.services.codewhisperer.codetest.testGenStoppedError
4544
import software.aws.toolkits.jetbrains.services.codewhisperer.credentials.CodeWhispererClientAdaptor
@@ -135,7 +134,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
135134
}
136135
LOG.error(e) { "Unexpected error while creating test generation job" }
137136
val errorMessage = getTelemetryErrorMessage(e, CodeWhispererConstants.FeatureName.TEST_GENERATION)
138-
codeTestServerException(
137+
throw CodeTestException(
139138
"CreateTestJobError: $errorMessage",
140139
statusCode,
141140
"CreateTestJobError",
@@ -194,7 +193,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
194193
// update test summary card
195194
} else {
196195
// If job status is Completed and has no ShortAnswer then there might be some issue in the backend.
197-
codeTestServerException(
196+
throw CodeTestException(
198197
"TestGenFailedError: " + message("testgen.message.failed"),
199198
500,
200199
"TestGenFailedError",
@@ -209,12 +208,12 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
209208
if (testGenerationResponse.testGenerationJob().shortAnswer() != null) {
210209
shortAnswer = parseShortAnswerString(testGenerationResponse.testGenerationJob().shortAnswer())
211210
if (shortAnswer.stopIteration == "true") {
212-
codeTestServerException("TestGenFailedError: ${shortAnswer.planSummary}", 400, "TestGenFailedError", shortAnswer.planSummary)
211+
throw CodeTestException("TestGenFailedError: ${shortAnswer.planSummary}", 400, "TestGenFailedError", shortAnswer.planSummary)
213212
}
214213
}
215214

216215
// If job status is Failed and has no ShortAnswer then there might be some issue in the backend.
217-
codeTestServerException(
216+
throw CodeTestException(
218217
"TestGenFailedError: " + message("testgen.message.failed"),
219218
500,
220219
"TestGenFailedError",
@@ -231,7 +230,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
231230
if (previousIterationContext == null && testGenerationResponse.testGenerationJob().shortAnswer() != null) {
232231
shortAnswer = parseShortAnswerString(testGenerationResponse.testGenerationJob().shortAnswer())
233232
if (shortAnswer.stopIteration == "true") {
234-
codeTestServerException("TestGenFailedError: ${shortAnswer.planSummary}", 400, "TestGenFailedError", shortAnswer.planSummary)
233+
throw CodeTestException("TestGenFailedError: ${shortAnswer.planSummary}", 400, "TestGenFailedError", shortAnswer.planSummary)
235234
}
236235
codeTestChatHelper.updateAnswer(
237236
CodeTestChatMessageContent(
@@ -263,7 +262,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
263262
},
264263
{ e ->
265264
LOG.error(e) { "ExportResultArchive failed: ${e.message}" }
266-
codeTestServerException(
265+
throw CodeTestException(
267266
"ExportResultsArchiveError: ${e.message}",
268267
500,
269268
"ExportResultsArchiveError",

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/codetest/CodeTestException.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,5 @@ internal fun cannotFindBuildArtifacts(errorMessage: String): Nothing =
3232
internal fun invalidSourceZipError(): Nothing =
3333
throw CodeTestException(message("codewhisperer.codescan.invalid_source_zip_telemetry"), 400, "InvalidSourceZipError")
3434

35-
fun codeTestServerException(
36-
errorMessage: String,
37-
statusCode: Int,
38-
code: String? = "DefaultError",
39-
uiMessage: String? = message(
40-
"testgen.error.generic_technical_error_message"
41-
),
42-
): Nothing =
43-
throw CodeTestException(errorMessage, statusCode, code, uiMessage)
44-
4535
fun testGenStoppedError(): Nothing =
4636
throw CodeTestException(message("testgen.message.cancelled"), 400, "TestGenCancelled", message("testgen.message.cancelled"))

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererZipUploadManager.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.CodeWhisp
2727
import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.CodeWhispererCodeScanSession.Companion.SERVER_SIDE_ENCRYPTION_CONTEXT
2828
import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.codeScanServerException
2929
import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.invalidSourceZipError
30-
import software.aws.toolkits.jetbrains.services.codewhisperer.codetest.codeTestServerException
30+
import software.aws.toolkits.jetbrains.services.codewhisperer.codetest.CodeTestException
3131
import software.aws.toolkits.jetbrains.services.codewhisperer.credentials.CodeWhispererClientAdaptor
3232
import software.aws.toolkits.resources.message
3333
import java.io.File
@@ -108,7 +108,7 @@ class CodeWhispererZipUploadManager(private val project: Project) {
108108
val errorMessage = getTelemetryErrorMessage(e, featureUseCase)
109109
when (featureUseCase) {
110110
CodeWhispererConstants.FeatureName.CODE_REVIEW -> codeScanServerException("CreateUploadUrlException: $errorMessage")
111-
CodeWhispererConstants.FeatureName.TEST_GENERATION -> codeTestServerException(
111+
CodeWhispererConstants.FeatureName.TEST_GENERATION -> throw CodeTestException(
112112
"UploadTestArtifactToS3Error: $errorMessage",
113113
403,
114114
"UploadTestArtifactToS3Error",
@@ -146,7 +146,7 @@ class CodeWhispererZipUploadManager(private val project: Project) {
146146
val errorMessage = getTelemetryErrorMessage(e, featureUseCase)
147147
when (featureUseCase) {
148148
CodeWhispererConstants.FeatureName.CODE_REVIEW -> codeScanServerException("CreateUploadUrlException: $errorMessage")
149-
CodeWhispererConstants.FeatureName.TEST_GENERATION -> codeTestServerException(
149+
CodeWhispererConstants.FeatureName.TEST_GENERATION -> throw CodeTestException(
150150
"CreateUploadUrlError: $errorMessage",
151151
500,
152152
"CreateUploadUrlError",

0 commit comments

Comments
 (0)