Skip to content

Commit b232e2e

Browse files
committed
Addressing PR
1 parent 218b43d commit b232e2e

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -295,30 +295,31 @@ export class TestController {
295295
tabID,
296296
'answer'
297297
)
298-
} else {
299-
getLogger().error('Too many requests.')
298+
}
299+
if (error.message.includes('Too many requests')) {
300+
getLogger().error(error.message)
300301
return this.messenger.sendErrorMessage(tooManyRequestErrorMessage, tabID)
301302
}
302303
}
303304
if (isAwsError(error)) {
304305
if (error.code === 'ThrottlingException') {
305306
// TODO: use the explicitly modeled exception reason for quota vs throttle{
306-
getLogger().error('Too many requests.')
307+
getLogger().error(error.message)
307308
this.messenger.sendErrorMessage(tooManyRequestErrorMessage, tabID)
308-
} else {
309-
// other service errors:
310-
// AccessDeniedException - should not happen because access is validated before this point in the client
311-
// ValidationException - shouldn't happen because client should not send malformed requests
312-
// ConflictException - should not happen because the client will maintain proper state
313-
// InternalServerException - shouldn't happen but needs to be caught
314-
getLogger().error('Other error message: %s', error.message)
315-
this.messenger.sendErrorMessage('', tabID)
309+
return
316310
}
317-
} else {
318-
// other unexpected errors (TODO enumerate all other failure cases)
319-
getLogger().error('Other error message: %s', error.uiMessage)
311+
// other service errors:
312+
// AccessDeniedException - should not happen because access is validated before this point in the client
313+
// ValidationException - shouldn't happen because client should not send malformed requests
314+
// ConflictException - should not happen because the client will maintain proper state
315+
// InternalServerException - shouldn't happen but needs to be caught
316+
getLogger().error('Other error message: %s', error.message)
320317
this.messenger.sendErrorMessage('', tabID)
318+
return
321319
}
320+
// other unexpected errors (TODO enumerate all other failure cases)
321+
getLogger().error('Other error message: %s', error.uiMessage)
322+
this.messenger.sendErrorMessage('', tabID)
322323
}
323324

324325
// 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)