gpt4 book ai didi

c# - AggregateException - AggregateException.Flatten().InnerException 代表什么?

转载 作者:IT王子 更新时间:2023-10-29 04:42:04 24 4
gpt4 key购买 nike

我一直在查看我们的一个应用程序中的一些代码,如下所示:

catch (AggregateException ae)
{
this._logger.Log(ae.Flatten().InnerException.ToString(), Category.Exception, Priority.High);
}

我的问题是这样的。我知道 AggregateException.Flatten() 的作用,也知道 AggregateException.Flatten().InnerExceptions 代表什么。但是,AggregateException.Flatten().InnerException (single) 代表什么?

最佳答案

它只是原始异常中的一个 non-AggregateExceptions。因此,例如,如果您有一个初始 AggregateException 为:

AggregateException
AggregateException
IOException("x")
IOException("y")
IOException("z")

然后扁平化结果的 InnerException 将作为 IOException("x")IOException("y")IOException(“z”)。我不相信有任何关于哪个的保证。 (我相信目前的行为会给出“z”版本......)这将是扁平化版本上的第一个 InnerExceptions,但应该被视为 所有原始非 AggregateExceptions 的联合,没有保证的顺序。

基本上 InnerException 对于 AggregateException 不是很有用。记录 所有 InnerExceptions... 或仅在顶级异常上调用 ToString() 会更有用,这将保留所有结构...

关于c# - AggregateException - AggregateException.Flatten().InnerException 代表什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13570855/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com