CopyObjectAsync method throws AmazonS3Exception when source object doesn't exist. #2996
-
Describe the bugWhen trying to copy not existing object s3 client throws an exception with error code NoSuchKey and Expected BehaviorI would say we should provide error in Also it's not clear how a library consumer should determine that it's an issue with source key, cause the only way I see here is to check that Current Behavior
Reproduction StepsExecute Possible SolutionDon't throw an exception but pass error context into Additional Information/ContextNo response AWS .NET SDK and/or Package version usedAWSSDK.S3 3.7.107.5 Targeted .NET Platform.NET 7 Operating System and versionOSX Ventura 13.4.1 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@olizarevichroman Good morning. Thanks for reporting the concern. The behavior to throw an exception is as per design. The behavior is also controlled by service models which may define what exceptions a particular service operation may throw (for example NoSuchKey). This behavior is uniform across all AWS SDK(s) and is unlikely to change. For your use case, you may develop a middleware with POCO object for each service operation that could have a shape with members like I'm converting this to Thanks, |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
@olizarevichroman Good morning. Thanks for reporting the concern. The behavior to throw an exception is as per design. The behavior is also controlled by service models which may define what exceptions a particular service operation may throw (for example NoSuchKey). This behavior is uniform across all AWS SDK(s) and is unlikely to change.
For your use case, you may develop a middleware with POCO object for each service operation that could have a shape with members like
StatusCode
and<ServiceOperation>Response
object, where your middleware would catch specific exceptions and returns POCO object with specified status code to the caller.I'm converting this to
Q&A
discussion since the beh…