我正在使用Golang SDK https://pkg.go.dev/github.com/aws/aws-sdk-go@v1.45.26/调试条件判断错误,并查找有关单次写入操作失败的原因的信息,但我只能看到错误消息_:"条件请求失败".在UpdateItemInput中使用参数ReturnValuesOnConditionCheckFailure:ALL_OLD时,没有提供具体原因的其他信息.对于TransactWriteItems,当使用相同的参数时,我可以看到条件判断失败的具体原因.我如何也可以获得单次写入操作的这些详细信息?参考:https://aws.amazon.com/about-aws/whats-new/2023/06/amazon-dynamodb-cost-failed-conditional-writes我使用的语法:

input := &dynamodb.UpdateItemInput{
        TableName:                           aws.String("DummyTable"),
        Key:                                 keyAttr,
        ExpressionAttributeValues:           updateExpr.Values(),
        ExpressionAttributeNames:            updateExpr.Names(),
        ConditionExpression:                 updateExpr.Condition(),
        ReturnValues:                        aws.String(dynamodb.ReturnValueAllOld),
        UpdateExpression:                    updateExpr.Update(),
        ReturnValuesOnConditionCheckFailure: aws.String(dynamodb.ReturnValuesOnConditionCheckFailureAllOld),
}
output, err := dl.ddbI.UpdateItem(input)

推荐答案

该项目应在误差分量内,通常为error.response.Item.

例如,在Python中:

except botocore.exceptions.ClientError as error:
    if error.response["Error"]["Code"] == "ConditionalCheckFailedException":
        print("The conditional expression is not met")
        current_value = error.response.get("Item")

Note: if you're using DynamoDB Local this feature does not yet exist

Go相关问答推荐

Pulumi-S3-当策略依赖于访问点时,如何将AccesspintPolicy附加到访问点

如何使用Promela建模语言对Golang RWLock进行建模

如果第一次匹配条件,如何跳过切片中的值

go-chi: 接受带有反斜杠的 url 路径参数

Go:如何在不加载正文的情况下创建 http 代理通行证

Go 中的 protobuf FieldMask 解组

Golang Docker Selenium Chrome

杜松子wine 和中间件

正确的 shell 程序进入 golang alpine docker 容器的入口点?

从给定顶点查找图形中所有闭合路径的算法

由于 main.go 文件中的本地包导入导致构建 docker 容器时出错

上传图片失败,出现错误dial tcp: lookup api.cloudinary.com: no such host

数据流中的无根单元错误,从 Golang 中的 PubSub 到 Bigquery

从 Makefile 运行时权限被拒绝

为什么时间很短.睡眠时间比基准测试中要求的(约 300 ns)长?

github.com/rs/zerolog 字段的延迟判断

如果服务器在客户端的 gRPC 中不可用,则等待的方法

跟踪长时间运行的任务的进度 - 正确的方法

退格字符在围棋操场中不起作用

在 Go 泛型中,如何对联合约束中的类型使用通用方法?