@@ -8,6 +8,8 @@ import { AwsClient, AwsClientConstructor, AwsCommand, AwsCommandConstructor } fr
88import { PaginationConfiguration , Paginator } from '@aws-sdk/types'
99import { AsyncCollection , toCollection } from '../utilities/asyncCollection'
1010import { isDefined } from '../utilities/tsUtils'
11+ import { withPerfLogOnFail } from '../logger/perfLogger'
12+ import { truncateProps } from '../utilities/textUtilities'
1113
1214type SDKPaginator < C , CommandInput extends object , CommandOutput extends object > = (
1315 config : Omit < PaginationConfiguration , 'client' > & { client : C } ,
@@ -35,7 +37,14 @@ export abstract class ClientWrapper<C extends AwsClient> implements vscode.Dispo
3537 CommandOptions extends CommandInput ,
3638 Command extends AwsCommand < CommandInput , CommandOutput > ,
3739 > ( command : AwsCommandConstructor < CommandInput , Command > , commandOptions : CommandOptions ) : Promise < CommandOutput > {
38- return await this . getClient ( ) . send ( new command ( commandOptions ) )
40+ const makeRequest = withPerfLogOnFail (
41+ 'API Request' ,
42+ ( ) => this . getClient ( ) . send ( new command ( commandOptions ) ) ,
43+ truncateProps ( commandOptions , 20 , [ 'nextToken' ] ) ,
44+ mapNameToCode
45+ )
46+
47+ return makeRequest ( )
3948 }
4049
4150 protected makePaginatedRequest < CommandInput extends object , CommandOutput extends object , Output extends object > (
@@ -65,3 +74,7 @@ export abstract class ClientWrapper<C extends AwsClient> implements vscode.Dispo
6574 this . client ?. destroy ( )
6675 }
6776}
77+
78+ function mapNameToCode < E extends Error > ( e : E ) : E & { code : string } {
79+ return { ...e , message : e . message , name : e . name , stack : e . stack , code : e . message }
80+ }
0 commit comments