public void DoRiskyThings(List<Action> tasks)
{
List<Exception> exceptions = new List<Exception>();
foreach(Action task in tasks)
{
try {task()}
catch (Exception e) {exceptions.Add(e)};
}
if (exceptions.Any())
{
//... what goes here?
}
}
Run Code Online (Sandbox Code Playgroud)
我想保留所有信息(特别是消息和堆栈跟踪).