你知道为什么会发生这种情况吗?
代码如下:
try
{
var x = await Utils.Sales.GetUrl()
.PostJsonAsync(new Sale
{
MerchantId = Constants.Sandbox.MerchantId
})
.ReceiveJson<Sale>();
var b = x;
}
catch (FlurlHttpTimeoutException)
{
//LogError("Timed out!"); //todo:
}
catch (FlurlHttpException ex)
{
var x = ex.Message;
//todo:
//if (ex.Call.Response != null)
// LogError("Failed with response code " + call.Response.StatusCode);
//else
// LogError("Totally failed before getting a response! " + ex.Message);
}
catch (Exception ex)
{
var a = ex.Message;
}下面是输出(这是我知道异常被抛出的唯一原因):

发布于 2016-10-10 10:08:34
也许这个页面会对https://msdn.microsoft.com/zh-cn/library/jj619227.aspx有所帮助
对不起,没有英文版本,你可以试试谷歌翻译。
捕获异常类型或等待代码有问题。
尝试使用此方法捕获异常:`
try
{
await t1;
}
catch (AggregateException ex)
{
var innerEx = ex.InnerExceptions[0];
if (innerEx is NotSupportedException)
{
...
}
else if (innerEx is NotImplementedException)
{
...
}
else
{
...
}
}https://stackoverflow.com/questions/39950312
复制相似问题