@@ -10,8 +10,8 @@ import * as EditorContext from '../util/editorContext'
1010import * as CodeWhispererConstants from '../models/constants'
1111import { ConfigurationEntry , GetRecommendationsResponse , vsCodeState } from '../models/model'
1212import { runtimeLanguageContext } from '../util/runtimeLanguageContext'
13- import { ServiceException } from '@smithy/smithy-client '
14- import { isServiceException } from '../../shared/errors'
13+ import { AWSError } from 'aws-sdk '
14+ import { isAwsError } from '../../shared/errors'
1515import { TelemetryHelper } from '../util/telemetryHelper'
1616import { getLogger } from '../../shared/logger/logger'
1717import { hasVendedIamCredentials } from '../../auth/auth'
@@ -290,14 +290,14 @@ export class RecommendationHandler {
290290 latency = startTime !== 0 ? Date . now ( ) - startTime : 0
291291 }
292292 getLogger ( ) . error ( 'amazonq inline-suggest: Invocation Exception : %s' , ( error as Error ) . message )
293- if ( isServiceException ( error ) ) {
293+ if ( isAwsError ( error ) ) {
294294 errorMessage = error . message
295- requestId = error . $metadata . requestId || ''
296- errorCode = error . name
297- reason = `CodeWhisperer Invocation Exception: ${ error ?. name ?? 'unknown' } `
295+ requestId = error . requestId || ''
296+ errorCode = error . code
297+ reason = `CodeWhisperer Invocation Exception: ${ error ?. code ?? error ?. name ?? 'unknown' } `
298298 await this . onThrottlingException ( error , triggerType )
299299
300- if ( error ?. name === 'AccessDeniedException' && errorMessage ?. includes ( 'no identity-based policy' ) ) {
300+ if ( error ?. code === 'AccessDeniedException' && errorMessage ?. includes ( 'no identity-based policy' ) ) {
301301 getLogger ( ) . error ( 'amazonq inline-suggest: AccessDeniedException : %s' , ( error as Error ) . message )
302302 void vscode . window
303303 . showErrorMessage ( `CodeWhisperer: ${ error ?. message } ` , CodeWhispererConstants . settingsLearnMore )
@@ -574,9 +574,9 @@ export class RecommendationHandler {
574574 return true
575575 }
576576
577- async onThrottlingException ( awsError : ServiceException , triggerType : CodewhispererTriggerType ) {
577+ async onThrottlingException ( awsError : AWSError , triggerType : CodewhispererTriggerType ) {
578578 if (
579- awsError . name === 'ThrottlingException' &&
579+ awsError . code === 'ThrottlingException' &&
580580 awsError . message . includes ( CodeWhispererConstants . throttlingMessage )
581581 ) {
582582 if ( triggerType === 'OnDemand' ) {
0 commit comments