Skip to content

Commit fb76514

Browse files
fix: LLD not printing errors #150 (#151)
1 parent d36fab9 commit fb76514

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/cloudFormation.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Logger } from './logger.js';
99
import * as yaml from 'yaml';
1010

1111
let cloudFormationClient: CloudFormationClient;
12+
const originalConsoleError = console.error;
1213

1314
/**
1415
* Get CloudFormation stack template
@@ -84,13 +85,16 @@ async function getCloudFormationResources(
8485
stackName: string,
8586
awsConfiguration: AwsConfiguration,
8687
) {
88+
let ListStackResourcesCommand: typeof ListStackResourcesCommandType;
8789
// temporary disable console.error because SAM framework outputs useless errors
88-
const originalConsoleError = console.error;
89-
console.error = function () {};
90-
const { ListStackResourcesCommand } = await import(
91-
'@aws-sdk/client-cloudformation'
92-
);
93-
console.error = originalConsoleError;
90+
try {
91+
console.error = function () {};
92+
93+
const clientCloudFormation = await import('@aws-sdk/client-cloudformation');
94+
ListStackResourcesCommand = clientCloudFormation.ListStackResourcesCommand;
95+
} finally {
96+
console.error = originalConsoleError;
97+
}
9498

9599
const cloudFormationClient: CloudFormationClient =
96100
await getCloudFormationClient(awsConfiguration);

0 commit comments

Comments
 (0)