Skip to content

Commit 33d79cb

Browse files
committed
show customer facing message
changelog logic
1 parent 8b02b85 commit 33d79cb

File tree

4 files changed

+22
-31
lines changed

4 files changed

+22
-31
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "/test: show customer facing error message"
4+
}

packages/core/src/amazonqTest/chat/controller/controller.ts

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -309,26 +309,13 @@ export class TestController {
309309
undefined,
310310
isCancel ? 'CANCELLED' : 'FAILED'
311311
)
312-
if (session.stopIteration) {
313-
// Error from Science
314-
this.messenger.sendMessage(
315-
data.error.uiMessage.replaceAll('```', ''),
316-
data.tabID,
317-
'answer',
318-
'testGenErrorMessage',
319-
this.getFeedbackButtons()
320-
)
321-
} else {
322-
isCancel
323-
? this.messenger.sendMessage(
324-
data.error.uiMessage,
325-
data.tabID,
326-
'answer',
327-
'testGenErrorMessage',
328-
this.getFeedbackButtons()
329-
)
330-
: this.sendErrorMessage(data)
331-
}
312+
this.messenger.sendMessage(
313+
data.error.uiMessage.replaceAll('```', ''),
314+
data.tabID,
315+
'answer',
316+
'testGenErrorMessage',
317+
this.getFeedbackButtons()
318+
)
332319
await this.sessionCleanUp()
333320
return
334321
}

packages/core/src/codewhisperer/commands/startTestGeneration.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import { ChatSessionManager } from '../../amazonqTest/chat/storages/chatSession'
2020
import { ChildProcess, spawn } from 'child_process' // eslint-disable-line no-restricted-imports
2121
import { BuildStatus } from '../../amazonqTest/chat/session/session'
2222
import { fs } from '../../shared/fs/fs'
23-
import { TestGenerationJobStatus } from '../models/constants'
24-
import { TestGenFailedError } from '../../amazonqTest/error'
2523
import { Range } from '../client/codewhispereruserclient'
2624

2725
// eslint-disable-next-line unicorn/no-null
@@ -112,18 +110,13 @@ export async function startTestGenerationProcess(
112110
if (!shouldContinueRunning(tabID)) {
113111
return
114112
}
115-
const jobStatus = await pollTestJobStatus(
113+
await pollTestJobStatus(
116114
testJob.testGenerationJob.testGenerationJobId,
117115
testJob.testGenerationJob.testGenerationJobGroupName,
118116
filePath,
119117
initialExecution
120118
)
121119
// TODO: Send status to test summary
122-
if (jobStatus === TestGenerationJobStatus.FAILED) {
123-
session.numberOfTestsGenerated = 0
124-
logger.verbose(`Test generation failed.`)
125-
throw new TestGenFailedError()
126-
}
127120
throwIfCancelled()
128121
if (!shouldContinueRunning(tabID)) {
129122
return

packages/core/src/codewhisperer/service/testGenHandler.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
CreateUploadUrlError,
1919
ExportResultsArchiveError,
2020
InvalidSourceZipError,
21+
TestGenFailedError,
2122
TestGenStoppedError,
2223
TestGenTimedOutError,
2324
} from '../../amazonqTest/error'
@@ -193,9 +194,15 @@ export async function pollTestJobStatus(
193194
}
194195
}
195196
ChatSessionManager.Instance.getSession().targetFileInfo = targetFileInfo
196-
if (resp.testGenerationJob?.status !== CodeWhispererConstants.TestGenerationJobStatus.IN_PROGRESS) {
197-
// This can be FAILED or COMPLETED
198-
status = resp.testGenerationJob?.status as CodeWhispererConstants.TestGenerationJobStatus
197+
status = resp.testGenerationJob?.status as CodeWhispererConstants.TestGenerationJobStatus
198+
if (status === CodeWhispererConstants.TestGenerationJobStatus.FAILED) {
199+
session.numberOfTestsGenerated = 0
200+
logger.verbose(`Test generation failed.`)
201+
if (resp.testGenerationJob?.jobStatusReason) {
202+
throw new TestGenFailedError(resp.testGenerationJob?.jobStatusReason)
203+
}
204+
throw new TestGenFailedError()
205+
} else if (status === CodeWhispererConstants.TestGenerationJobStatus.COMPLETED) {
199206
logger.verbose(`testgen job status: ${status}`)
200207
logger.verbose(`Complete polling test job status.`)
201208
break

0 commit comments

Comments
 (0)