如何在 AWSSDK.DynamoDBv2 的 ResourceNotFoundException 中获取资源名称
How get resource name in ResourceNotFoundException of AWSSDK.DynamoDBv2
我正在使用 ServiceStack.Aws,我收到 ResourceNotFoundException,但我看不到它要查找的资源名称。 ¿资源名称在异常中发送? ¿我怎样才能得到它?
我的模型 class 是(table 并且索引名称存在)
[DynamoDBTable("SOME-TABLE-NAME")]
public class Company
{
[DynamoDBHashKey]
public string CompanyId { get; set; }
[DynamoDBGlobalSecondaryIndexHashKey("SOME-INDEX-NAME")]
public string ShortName { get; set; }
public string DocumentNumber { get; set; }
public string FullName { get; set; }
public string Address { get; set; }
public DateTime CreatedAt { get; set; }
}
我的密码是
var awsDb = new AmazonDynamoDBClient();
var db = new PocoDynamo(awsDb);
db.RegisterTable<Company>();
try
{
db.PutItem<Company>(new Company
{
Address = "Some address #some number",
CompanyId = Guid.NewGuid().ToString(),
CreatedAt = DateTime.Now,
DocumentNumber = "11.222.333-4",
FullName = "Some company name",
ShortName = "ShortName"
});
}
catch (ResourceNotFoundException ex)
{
}
catch (Exception ex)
{
}
在我的 app.config 我有(路径和配置文件名称存在。区域也可以)
<aws region="us-east-1" profileName="profile-name" profilesLocation="some-path\certificados.txt">
</aws>
编辑:问题是 ServiceStack 不使用 AWS 属性。所以,我将 DynamoDBTable 更改为 Alias,一切正常
ServiceStack.Aws's PocoDynamo automatically retries temporary exceptions behind-the-scenes so the original AWS exception may have been retried. I've just added an ExceptionFilter
in this commit 这将让您检查 AWS DynamoDB 客户端抛出的每个异常:
var dynamo = new PocoDynamo(awsDynamoClient) {
ExceptionFilter = ex => ex.Message.Print();
};
ExceptionFilter 从 v4.0.61 开始可用,现在 available on MyGet。
此外 [DynamoDBGlobalSecondaryIndexHashKey]
属性在 PocoDynamo 中无效,请参阅 creating Global Indexes with PocoDynamo 上的文档。
我正在使用 ServiceStack.Aws,我收到 ResourceNotFoundException,但我看不到它要查找的资源名称。 ¿资源名称在异常中发送? ¿我怎样才能得到它?
我的模型 class 是(table 并且索引名称存在)
[DynamoDBTable("SOME-TABLE-NAME")]
public class Company
{
[DynamoDBHashKey]
public string CompanyId { get; set; }
[DynamoDBGlobalSecondaryIndexHashKey("SOME-INDEX-NAME")]
public string ShortName { get; set; }
public string DocumentNumber { get; set; }
public string FullName { get; set; }
public string Address { get; set; }
public DateTime CreatedAt { get; set; }
}
我的密码是
var awsDb = new AmazonDynamoDBClient();
var db = new PocoDynamo(awsDb);
db.RegisterTable<Company>();
try
{
db.PutItem<Company>(new Company
{
Address = "Some address #some number",
CompanyId = Guid.NewGuid().ToString(),
CreatedAt = DateTime.Now,
DocumentNumber = "11.222.333-4",
FullName = "Some company name",
ShortName = "ShortName"
});
}
catch (ResourceNotFoundException ex)
{
}
catch (Exception ex)
{
}
在我的 app.config 我有(路径和配置文件名称存在。区域也可以)
<aws region="us-east-1" profileName="profile-name" profilesLocation="some-path\certificados.txt">
</aws>
编辑:问题是 ServiceStack 不使用 AWS 属性。所以,我将 DynamoDBTable 更改为 Alias,一切正常
ServiceStack.Aws's PocoDynamo automatically retries temporary exceptions behind-the-scenes so the original AWS exception may have been retried. I've just added an ExceptionFilter
in this commit 这将让您检查 AWS DynamoDB 客户端抛出的每个异常:
var dynamo = new PocoDynamo(awsDynamoClient) {
ExceptionFilter = ex => ex.Message.Print();
};
ExceptionFilter 从 v4.0.61 开始可用,现在 available on MyGet。
此外 [DynamoDBGlobalSecondaryIndexHashKey]
属性在 PocoDynamo 中无效,请参阅 creating Global Indexes with PocoDynamo 上的文档。