Skip to content

Commit 4ee91ef

Browse files
committed
Addressing comments
1 parent 7c05f28 commit 4ee91ef

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

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

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ export class TestController {
263263
reasonDesc: telemetryErrorMessage,
264264
isSupportedLanguage: true,
265265
credentialStartUrl: AuthUtil.instance.startUrl,
266-
httpStatusCode: data.error.statusCode ?? 0, // If status code is 0, need to investigate where this is originating from.
266+
httpStatusCode: data.error.statusCode ?? '0', // If status code is 0, need to investigate where this is originating from.
267267
})
268268
if (session.stopIteration) {
269269
// Error from Science
@@ -292,30 +292,31 @@ export class TestController {
292292
tabID,
293293
'answer'
294294
)
295-
} else {
296-
getLogger().error('Too many requests.')
295+
}
296+
if (error.message.includes('Too many requests')) {
297+
getLogger().error(error.message)
297298
return this.messenger.sendErrorMessage(tooManyRequestErrorMessage, tabID)
298299
}
299300
}
300301
if (isAwsError(error)) {
301302
if (error.code === 'ThrottlingException') {
302303
// TODO: use the explicitly modeled exception reason for quota vs throttle{
303-
getLogger().error('Too many requests.')
304+
getLogger().error(error.message)
304305
this.messenger.sendErrorMessage(tooManyRequestErrorMessage, tabID)
305-
} else {
306-
// other service errors:
307-
// AccessDeniedException - should not happen because access is validated before this point in the client
308-
// ValidationException - shouldn't happen because client should not send malformed requests
309-
// ConflictException - should not happen because the client will maintain proper state
310-
// InternalServerException - shouldn't happen but needs to be caught
311-
getLogger().error('Other error message: %s', error.message)
312-
this.messenger.sendErrorMessage('', tabID)
306+
return
313307
}
314-
} else {
315-
// other unexpected errors (TODO enumerate all other failure cases)
316-
getLogger().error('Other error message: %s', error.uiMessage)
308+
// other service errors:
309+
// AccessDeniedException - should not happen because access is validated before this point in the client
310+
// ValidationException - shouldn't happen because client should not send malformed requests
311+
// ConflictException - should not happen because the client will maintain proper state
312+
// InternalServerException - shouldn't happen but needs to be caught
313+
getLogger().error('Other error message: %s', error.message)
317314
this.messenger.sendErrorMessage('', tabID)
315+
return
318316
}
317+
// other unexpected errors (TODO enumerate all other failure cases)
318+
getLogger().error('Other error message: %s', error.uiMessage)
319+
this.messenger.sendErrorMessage('', tabID)
319320
}
320321

321322
// This function handles actions if user clicked on any Button one of these cases will be executed

packages/core/src/amazonqTest/error.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
import { ToolkitError } from '../shared/errors'
66

7-
export const techinalErrorCustomerFacingMessage =
7+
export const technicalErrorCustomerFacingMessage =
88
'I am experiencing technical difficulties at the moment. Please try again in a few minutes.'
99
const defaultTestGenErrorMessage = 'Amazon Q encountered an error while generating tests. Try again later.'
1010
export class TestGenError extends ToolkitError {
@@ -29,17 +29,17 @@ export class InvalidSourceZipError extends TestGenError {
2929
}
3030
export class CreateUploadUrlError extends TestGenError {
3131
constructor(errorMessage: string, errorCode: string) {
32-
super(errorMessage, 'CreateUploadUrlError', errorCode, techinalErrorCustomerFacingMessage)
32+
super(errorMessage, 'CreateUploadUrlError', errorCode, technicalErrorCustomerFacingMessage)
3333
}
3434
}
3535
export class UploadTestArtifactToS3Error extends TestGenError {
36-
constructor(error: string) {
37-
super(error, 'UploadTestArtifactToS3Error', '500', techinalErrorCustomerFacingMessage)
36+
constructor(error: string, statusCode?: string) {
37+
super(error, 'UploadTestArtifactToS3Error', statusCode ?? '400', technicalErrorCustomerFacingMessage)
3838
}
3939
}
4040
export class CreateTestJobError extends TestGenError {
4141
constructor(error: string, code: string) {
42-
super(error, 'CreateTestJobError', code, techinalErrorCustomerFacingMessage)
42+
super(error, 'CreateTestJobError', code, technicalErrorCustomerFacingMessage)
4343
}
4444
}
4545
export class TestGenTimedOutError extends TestGenError {
@@ -48,7 +48,7 @@ export class TestGenTimedOutError extends TestGenError {
4848
'Test generation failed. Amazon Q timed out.',
4949
'TestGenTimedOutError',
5050
'500',
51-
techinalErrorCustomerFacingMessage
51+
technicalErrorCustomerFacingMessage
5252
)
5353
}
5454
}
@@ -63,7 +63,7 @@ export class TestGenFailedError extends TestGenError {
6363
error ?? 'Test generation failed',
6464
'TestGenFailedError',
6565
code,
66-
error ?? techinalErrorCustomerFacingMessage
66+
error ?? technicalErrorCustomerFacingMessage
6767
)
6868
}
6969
}
@@ -73,7 +73,7 @@ export class ExportResultsArchiveError extends TestGenError {
7373
error ?? 'Test generation failed',
7474
'ExportResultsArchiveError',
7575
statusCode ?? '400',
76-
techinalErrorCustomerFacingMessage
76+
technicalErrorCustomerFacingMessage
7777
)
7878
}
7979
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,9 @@ export async function uploadArtifactToS3(
384384
} else {
385385
errorMessage = errorDesc ?? defaultMessage
386386
}
387-
throw isCodeScan ? new UploadArtifactToS3Error(errorMessage) : new UploadTestArtifactToS3Error(errorMessage)
387+
throw isCodeScan
388+
? new UploadArtifactToS3Error(errorMessage)
389+
: new UploadTestArtifactToS3Error(errorMessage, (error as any).statusCode)
388390
}
389391
}
390392

0 commit comments

Comments
 (0)