@@ -241,70 +241,72 @@ export class TestController {
241
241
// eslint-disable-next-line unicorn/no-null
242
242
this . messenger . sendUpdatePromptProgress ( data . tabID , null )
243
243
const session = this . sessionStorage . getSession ( )
244
- const isCancel = data . error . message === unitTestGenerationCancelMessage
245
-
244
+ const isCancel = data . error . customerFacingMessage === unitTestGenerationCancelMessage
246
245
TelemetryHelper . instance . sendTestGenerationToolkitEvent (
247
246
session ,
248
247
true ,
249
248
isCancel ? 'Cancelled' : 'Failed' ,
250
249
session . startTestGenerationRequestId ,
251
250
performance . now ( ) - session . testGenerationStartTime ,
252
251
getTelemetryReasonDesc ( data . error ) ,
252
+ data . error . statusCode ?? '0' , // If status code is 0, need to investigate where this is originating from.
253
253
session . isCodeBlockSelected ,
254
254
session . artifactsUploadDuration ,
255
255
session . srcPayloadSize ,
256
256
session . srcZipFileSize
257
257
)
258
-
259
258
if ( session . stopIteration ) {
260
259
// Error from Science
261
- this . messenger . sendMessage ( data . error . message . replaceAll ( '```' , '' ) , data . tabID , 'answer' )
260
+ this . messenger . sendMessage ( data . error . customerFacingMessage . replaceAll ( '```' , '' ) , data . tabID , 'answer' )
262
261
} else {
263
262
isCancel
264
- ? this . messenger . sendMessage ( data . error . message , data . tabID , 'answer' )
263
+ ? this . messenger . sendMessage ( data . error . customerFacingMessage , data . tabID , 'answer' )
265
264
: this . sendErrorMessage ( data )
266
265
}
267
266
await this . sessionCleanUp ( )
268
267
return
269
268
}
270
269
// Client side error messages
271
- private sendErrorMessage ( data : { tabID : string ; error : { code : string ; message : string } } ) {
270
+ private sendErrorMessage ( data : {
271
+ tabID : string
272
+ error : { customerFacingMessage : string ; message : string ; code : string ; statusCode : string }
273
+ } ) {
272
274
const { error, tabID } = data
273
275
276
+ // If user reached montly limit for builderId
277
+ if ( error . code === 'CreateTestJobError' ) {
278
+ if ( error . message . includes ( CodeWhispererConstants . utgLimitReached ) ) {
279
+ getLogger ( ) . error ( 'Monthly quota reached for QSDA actions.' )
280
+ return this . messenger . sendMessage (
281
+ i18n ( 'AWS.amazonq.featureDev.error.monthlyLimitReached' ) ,
282
+ tabID ,
283
+ 'answer'
284
+ )
285
+ } else {
286
+ getLogger ( ) . error ( 'Too many requests.' )
287
+ // TODO: move to constants file
288
+ return this . messenger . sendErrorMessage ( 'Too many requests. Please wait before retrying.' , tabID )
289
+ }
290
+ }
274
291
if ( isAwsError ( error ) ) {
275
292
if ( error . code === 'ThrottlingException' ) {
276
- // TODO: use the explicitly modeled exception reason for quota vs throttle
277
- if ( error . message . includes ( CodeWhispererConstants . utgLimitReached ) ) {
278
- getLogger ( ) . error ( 'Monthly quota reached for QSDA actions.' )
279
- return this . messenger . sendMessage (
280
- i18n ( 'AWS.amazonq.featureDev.error.monthlyLimitReached' ) ,
281
- tabID ,
282
- 'answer'
283
- )
284
- } else {
285
- getLogger ( ) . error ( 'Too many requests.' )
286
- // TODO: move to constants file
287
- this . messenger . sendErrorMessage ( 'Too many requests. Please wait before retrying.' , tabID )
288
- }
293
+ // TODO: use the explicitly modeled exception reason for quota vs throttle{
294
+ getLogger ( ) . error ( 'Too many requests.' )
295
+ // TODO: move to constants file
296
+ this . messenger . sendErrorMessage ( 'Too many requests. Please wait before retrying.' , tabID )
289
297
} else {
290
298
// other service errors:
291
299
// AccessDeniedException - should not happen because access is validated before this point in the client
292
300
// ValidationException - shouldn't happen because client should not send malformed requests
293
301
// ConflictException - should not happen because the client will maintain proper state
294
302
// InternalServerException - shouldn't happen but needs to be caught
295
303
getLogger ( ) . error ( 'Other error message: %s' , error . message )
296
- this . messenger . sendErrorMessage (
297
- 'Encountered an unexpected error when generating tests. Please try again' ,
298
- tabID
299
- )
304
+ this . messenger . sendErrorMessage ( '' , tabID )
300
305
}
301
306
} else {
302
307
// other unexpected errors (TODO enumerate all other failure cases)
303
- getLogger ( ) . error ( 'Other error message: %s' , error . message )
304
- this . messenger . sendErrorMessage (
305
- 'Encountered an unexpected error when generating tests. Please try again' ,
306
- tabID
307
- )
308
+ getLogger ( ) . error ( 'Other error message: %s' , error . customerFacingMessage )
309
+ this . messenger . sendErrorMessage ( '' , tabID )
308
310
}
309
311
}
310
312
@@ -721,6 +723,7 @@ export class TestController {
721
723
session . startTestGenerationRequestId ,
722
724
session . latencyOfTestGeneration ,
723
725
undefined ,
726
+ '200' ,
724
727
session . isCodeBlockSelected ,
725
728
session . artifactsUploadDuration ,
726
729
session . srcPayloadSize ,
@@ -734,7 +737,6 @@ export class TestController {
734
737
)
735
738
736
739
await this . endSession ( message , FollowUpTypes . SkipBuildAndFinish )
737
- await this . sessionCleanUp ( )
738
740
return
739
741
740
742
if ( session . listOfTestGenerationJobId . length === 1 ) {
@@ -842,18 +844,16 @@ export class TestController {
842
844
session . startTestGenerationRequestId ,
843
845
session . latencyOfTestGeneration ,
844
846
undefined ,
847
+ '200' ,
845
848
session . isCodeBlockSelected ,
846
849
session . artifactsUploadDuration ,
847
- session . srcPayloadSize ,
848
- session . srcZipFileSize ,
849
850
0 ,
850
851
0 ,
851
852
0 ,
852
853
session . charsOfCodeGenerated ,
853
854
session . numberOfTestsGenerated ,
854
855
session . linesOfCodeGenerated
855
856
)
856
-
857
857
telemetry . ui_click . emit ( { elementId : 'unitTestGeneration_rejectDiff' } )
858
858
}
859
859
@@ -1297,8 +1297,17 @@ export class TestController {
1297
1297
'Deleting output.log and temp result directory. testGenerationLogsDir: %s' ,
1298
1298
testGenerationLogsDir
1299
1299
)
1300
- await fs . delete ( path . join ( testGenerationLogsDir , 'output.log' ) )
1301
- await fs . delete ( this . tempResultDirPath , { recursive : true } )
1300
+ if ( await fs . existsFile ( path . join ( testGenerationLogsDir , 'output.log' ) ) ) {
1301
+ await fs . delete ( path . join ( testGenerationLogsDir , 'output.log' ) )
1302
+ }
1303
+ if (
1304
+ await fs
1305
+ . stat ( this . tempResultDirPath )
1306
+ . then ( ( ) => true )
1307
+ . catch ( ( ) => false )
1308
+ ) {
1309
+ await fs . delete ( this . tempResultDirPath , { recursive : true } )
1310
+ }
1302
1311
}
1303
1312
1304
1313
// TODO: return build command when product approves
0 commit comments