Skip to content

why does the sdk raise an exception when an object is not found? #2513

Answered by ashishdhingra
Arikael asked this question in Q&A
Discussion options

You must be logged in to vote

@Arikael the GetObjectAsync() invokes GetObject S3 API operation and is expected to return the existing object with the content body. The Permissions section specifies that If the object you request does not exist, the error Amazon S3 returns depends on whether you also have the s3:ListBucket permission. The error is returned by the S3 service in the form of HTTP status code, either 404 or 403. All AWS SDK(s) are generated from service models, for S3 the model is here and For GetObject it specifies NoSuchKey as one of the errors. this behavior is consistent across all the SDK(s) and the errors the possibly handled by throwing exceptions.

CCing @normj for additional inputs.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Arikael
Comment options

Answer selected by Arikael
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. s3
3 participants