DVA-C02 exam dumps

DVA-C02 practice question 350 of 399

AWS Certified Developer - Associate. Associate level, Amazon Web Services. Free question with the correct answer and a full explanation.

DVA-C02 Question 350

Single answer

You are developing an application using the AWS SDK for Python (Boto3) to interact with an Amazon S3 bucket. During testing, your application throws an exception when attempting to retrieve an object that does not exist in the bucket. Which exception should you handle in your code to address this scenario?

  1. A

    NoSuchKey

  2. B

    AccessDenied

  3. C

    BucketNotFound

  4. D

    ClientError

Show answer and explanation

Correct answer: A

Explanation

When working with the AWS SDK, specific exceptions like NoSuchKey allow developers to handle errors in a more granular way. In this case, when attempting to retrieve a non-existent object from an S3 bucket, the NoSuchKey exception should be handled to properly identify and respond to the issue.

  • A. Correct.

    NoSuchKey is the correct exception raised by the AWS SDK when attempting to access a non-existent object in an S3 bucket.

  • B. Incorrect.

    AccessDenied is an exception that occurs when the credentials used do not have the required permissions to access the resource, but it is not relevant to this scenario where the object simply does not exist.

  • C. Incorrect.

    BucketNotFound is not a valid exception in the AWS SDK. A similar situation would raise a ClientError with a specific error code.

  • D. Incorrect.

    ClientError is a general exception that serves as a parent for many specific errors (e.g., NoSuchKey), but it is not the most appropriate choice to specifically handle the case of a missing object.

Timed practice exam

Take a DVA-C02 practice test under exam conditions

65 questions in 130 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam