假设我有一个返回 a 的方法,List<int>并且在获取它的过程中List<int>发生错误,因此无法收集数据。在方法中处理此异常的最佳方法是什么?该程序期望该方法返回一个列表,但由于无论出于何种原因发生了错误,它无法再执行此操作。我应该从方法返回什么?是否是调用代码捕获的自定义异常?
private List<int> GetData()
{
List<in> theData = new List<int>();
theData = ProcessThatGetsData(); //Error occurs in here
return theData; //What should be returned here?
}
一只甜甜圈
慕桂英546537
相关分类