Skip to content

Commit a4ec440

Browse files
committed
JavaScript (v3): S3 - Use a more likely error for PutBucketPolicy example.
1 parent 91bdd2a commit a4ec440

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

javascriptv3/example_code/s3/actions/put-bucket-policy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ export const main = async ({ bucketName, iamRoleArn }) => {
4343
} catch (caught) {
4444
if (
4545
caught instanceof S3ServiceException &&
46-
caught.name === "NoSuchBucket"
46+
caught.name === "MalformedPolicy"
4747
) {
4848
console.error(
49-
`Error from S3 while setting the bucket policy for the bucket "${bucketName}". The bucket doesn't exist.`,
49+
`Error from S3 while setting the bucket policy for the bucket "${bucketName}". The policy was malformed.`,
5050
);
5151
} else if (caught instanceof S3ServiceException) {
5252
console.error(

javascriptv3/example_code/s3/tests/put-bucket-policy.unit.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe("put-bucket-policy", () => {
3333

3434
it("should log a relevant error when the bucket doesn't exist", async () => {
3535
const error = new S3ServiceException("The specified bucket does not exist");
36-
error.name = "NoSuchBucket";
36+
error.name = "MalformedPolicy";
3737
const bucketName = "amzn-s3-demo-bucket";
3838
send.mockRejectedValueOnce(error);
3939

@@ -42,7 +42,7 @@ describe("put-bucket-policy", () => {
4242
await main({ bucketName });
4343

4444
expect(spy).toHaveBeenCalledWith(
45-
`Error from S3 while setting the bucket policy for the bucket "${bucketName}". The bucket doesn't exist.`,
45+
`Error from S3 while setting the bucket policy for the bucket "${bucketName}". The policy was malformed.`,
4646
);
4747
});
4848

0 commit comments

Comments
 (0)