Skip to content

Commit f5e043e

Browse files
committed
Updating the statusCode from String to Int
1 parent 456fa23 commit f5e043e

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ export class TestController {
254254
session.startTestGenerationRequestId,
255255
performance.now() - session.testGenerationStartTime,
256256
telemetryErrorMessage,
257-
data.error.statusCode ?? '0',
257+
data.error.statusCode.toString() ?? '0',
258258
session.isCodeBlockSelected,
259259
session.artifactsUploadDuration,
260260
session.srcPayloadSize,
@@ -280,10 +280,7 @@ export class TestController {
280280
return
281281
}
282282
// Client side error messages
283-
private sendErrorMessage(data: {
284-
tabID: string
285-
error: { uiMessage: string; message: string; code: string; statusCode: string }
286-
}) {
283+
private sendErrorMessage(data: { tabID: string; error: { uiMessage: string; message: string; code: string } }) {
287284
const { error, tabID } = data
288285

289286
// If user reached monthly limit for builderId

packages/core/src/amazonqTest/error.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,68 +11,68 @@ export class TestGenError extends ToolkitError {
1111
constructor(
1212
error: string,
1313
code: string,
14-
public statusCode: string,
14+
public statusCode: number,
1515
public uiMessage: string
1616
) {
1717
super(error, { code })
1818
}
1919
}
2020
export class ProjectZipError extends TestGenError {
2121
constructor(error: string) {
22-
super(error, 'ProjectZipError', '400', defaultTestGenErrorMessage)
22+
super(error, 'ProjectZipError', 400, defaultTestGenErrorMessage)
2323
}
2424
}
2525
export class InvalidSourceZipError extends TestGenError {
2626
constructor() {
27-
super('Failed to create valid source zip', 'InvalidSourceZipError', '400', defaultTestGenErrorMessage)
27+
super('Failed to create valid source zip', 'InvalidSourceZipError', 400, defaultTestGenErrorMessage)
2828
}
2929
}
3030
export class CreateUploadUrlError extends TestGenError {
31-
constructor(errorMessage: string, errorCode: string) {
31+
constructor(errorMessage: string, errorCode: number) {
3232
super(errorMessage, 'CreateUploadUrlError', errorCode, technicalErrorCustomerFacingMessage)
3333
}
3434
}
3535
export class UploadTestArtifactToS3Error extends TestGenError {
36-
constructor(error: string, statusCode?: string) {
37-
super(error, 'UploadTestArtifactToS3Error', statusCode ?? '400', technicalErrorCustomerFacingMessage)
36+
constructor(error: string, statusCode?: number) {
37+
super(error, 'UploadTestArtifactToS3Error', statusCode ?? 400, technicalErrorCustomerFacingMessage)
3838
}
3939
}
4040
export class CreateTestJobError extends TestGenError {
41-
constructor(error: string, code: string) {
42-
super(error, 'CreateTestJobError', code, technicalErrorCustomerFacingMessage)
41+
constructor(error: string, statusCode: number) {
42+
super(error, 'CreateTestJobError', statusCode, technicalErrorCustomerFacingMessage)
4343
}
4444
}
4545
export class TestGenTimedOutError extends TestGenError {
4646
constructor() {
4747
super(
4848
'Test generation failed. Amazon Q timed out.',
4949
'TestGenTimedOutError',
50-
'500',
50+
500,
5151
technicalErrorCustomerFacingMessage
5252
)
5353
}
5454
}
5555
export class TestGenStoppedError extends TestGenError {
5656
constructor() {
57-
super('Unit test generation cancelled.', 'TestGenCancelled', '400', 'Unit test generation cancelled.')
57+
super('Unit test generation cancelled.', 'TestGenCancelled', 400, 'Unit test generation cancelled.')
5858
}
5959
}
6060
export class TestGenFailedError extends TestGenError {
61-
constructor(code: string, error?: string) {
61+
constructor(statusCode: number, error?: string) {
6262
super(
6363
error ?? 'Test generation failed',
6464
'TestGenFailedError',
65-
code,
65+
statusCode,
6666
error ?? technicalErrorCustomerFacingMessage
6767
)
6868
}
6969
}
7070
export class ExportResultsArchiveError extends TestGenError {
71-
constructor(error?: string, statusCode?: string) {
71+
constructor(error?: string, statusCode?: number) {
7272
super(
7373
error ?? 'Test generation failed',
7474
'ExportResultsArchiveError',
75-
statusCode ?? '400',
75+
statusCode ?? 400,
7676
technicalErrorCustomerFacingMessage
7777
)
7878
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export async function startTestGenerationProcess(
122122
// TODO: Send status to test summary
123123
if (jobStatus === TestGenerationJobStatus.FAILED) {
124124
logger.verbose(`Test generation failed.`)
125-
throw new TestGenFailedError('500')
125+
throw new TestGenFailedError(500)
126126
}
127127
throwIfCancelled()
128128
if (!shouldContinueRunning(tabID)) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export async function pollTestJobStatus(
159159
// Stop the Unit test generation workflow if IDE receive stopIteration = true
160160
if (shortAnswer.stopIteration === 'true') {
161161
session.stopIteration = true
162-
throw new TestGenFailedError('400', shortAnswer.planSummary)
162+
throw new TestGenFailedError(400, shortAnswer.planSummary)
163163
}
164164
if (shortAnswer.numberOfTestMethods) {
165165
session.numberOfTestsGenerated = Number(shortAnswer.numberOfTestMethods)

0 commit comments

Comments
 (0)