Skip to content

Commit e385d89

Browse files
authored
Print code in removePromiseForCallExpression error message (#370)
1 parent 8ae6680 commit e385d89

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.changeset/early-students-kick.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"aws-sdk-js-codemod": patch
3+
---
4+
5+
Print code in removePromiseForCallExpression error message

src/transforms/v2-to-v3/apis/removePromiseForCallExpression.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ASTPath, CallExpression, MemberExpression } from "jscodeshift";
2+
import { print } from "recast";
23

34
export const removePromiseForCallExpression = (callExpression: ASTPath<CallExpression>) => {
45
switch (callExpression.parentPath.value.type) {
@@ -32,7 +33,9 @@ export const removePromiseForCallExpression = (callExpression: ASTPath<CallExpre
3233
}
3334
default:
3435
throw new Error(
35-
`Removal of .promise() not implemented for ${callExpression.parentPath.value.type}`
36+
`Removal of .promise() not implemented for parentPath: ${callExpression.parentPath.value.type}\n` +
37+
`Code processed: ${print(callExpression.parentPath.node).code}\n\n` +
38+
"Please report your use case on https://github.com/awslabs/aws-sdk-js-codemod\n"
3639
);
3740
}
3841
};

0 commit comments

Comments
 (0)