CSharpFunctionalExtensions
CSharpFunctionalExtensions copied to clipboard
return Result.Failure<CustomerBillingProfile>(e.Message) in Catchblock just hangs?
I have a method like this:
public async Task<Result<List<SubscribedSku>>> GetCustomerSubscribedSkuAsync(string customerId, string partnerId)
{
List<SubscribedSku> customerSubscribedSku = new List<SubscribedSku>();
try
{
var customerSubscribedSkusCollection = await partnerApiConnection.Customers.ById(customerId).SubscribedSkus.GetAsync();
if (customerSubscribedSkusCollection != null)
{
foreach (var sku in customerSubscribedSkusCollection.Items)
{
customerSubscribedSku.Add(sku);
}
}
else
{
_logger.LogWarning($"Found no subscriptionSkus for Customer with ID {customerId}");
}
}
catch (System.Exception e)
{
return Result.Failure<List<SubscribedSku>>(e.Message);
}
return Result.Ok(customerSubscribedSku);
}
And I call it like this:
Result<List<SubscribedSku>> customerSubscribedSku = await GetCustomerSubscribedSkuAsync(c.Id, partnerId);
if(customerSubscribedSku.IsFailure)
{
continue; // This is executed in foreach loop, if is failure, skip iteration
}
Problem is, when exception occurs in method and catch block is executed it just hangs there without returning "Result.Failure<List<SubscribedSku>>(e.Message);"??
I use this in a .NET Core 3.1 Workerservice.
Please advice.