如果我从被调用者而不是调用者抛出错误,是否可以接受/希望?或者我应该从被调用者那里获取错误信息,然后从调用者那里抛出异常?哪一种是首选/渴望的方式?
public static List<ProductBuilder> GetProductBuilders(GetProductsRequest productsRequest)
{
List<ProductBuilder> productBuilders = new List<ProductBuilder>();
...
... // Some logics to populate productBuilders
if (productBuilders.Count == 0)
{
Logger.LogMessage(productsRequest.SessionId, "No ProductBuilders were created.");
throw new ProductException(ProductException.ExceptionCode.SaveFailed, "No Service has qualified.");
}
return productBuilders;
}