Skip to content

Commit

Permalink
fix(bindings): adjust errorhandling for service instances (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil91 authored Apr 9, 2024
1 parent 8a045e5 commit 5b8f6cc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/clients/Dim.Clients/Api/Cf/CfClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public async Task<Guid> GetServicePlan(string servicePlanName, string servicePla
x.BrokerCatalog?.BrokerCatalogMetadata?.AutoSubscription?.AppName == servicePlanName);
if (servicePlans.Count() != 1)
{
throw new ServiceException($"There must be exactly one service plan with name {servicePlanName} and type {servicePlanType}");
throw new ServiceException($"There must be exactly one service plan with name {servicePlanName} and type {servicePlanType}", isRecoverable: !servicePlans.Any());
}

return servicePlans.Single().Id;
Expand Down Expand Up @@ -152,7 +152,7 @@ public async Task<Guid> GetSpace(string tenantName, CancellationToken cancellati
var spaces = response.Resources.Where(x => x.Name == spaceName);
if (spaces.Count() != 1)
{
throw new ServiceException($"There must be exactly one space with name {spaceName}");
throw new ServiceException($"There must be exactly one space with name {spaceName}", isRecoverable: !spaces.Any());
}

return spaces.Single().Id;
Expand Down Expand Up @@ -197,7 +197,7 @@ private async Task<Guid> GetServiceInstances(string tenantName, Guid? spaceId, C
var resources = response.Resources.Where(x => x.Name == name && x.Type == "managed" && (spaceId == null || x.Relationships.Space.Data.Id == spaceId.Value) && x.LastOperation.State == "succeeded");
if (resources.Count() != 1)
{
throw new ServiceException($"There must be exactly one service instance");
throw new ServiceException("There must be exactly one service instance", isRecoverable: !resources.Any());
}

return resources.Single().Id;
Expand Down Expand Up @@ -241,7 +241,7 @@ public async Task<Guid> GetServiceBinding(string tenantName, Guid spaceId, strin
var resources = response.Resources.Where(x => x.Relationships.ServiceInstance.Data.Id == serviceInstanceId);
if (resources.Count() != 1)
{
throw new ServiceException($"There must be exactly one service credential binding");
throw new ServiceException("There must be exactly one service credential binding", isRecoverable: !resources.Any());
}

return resources.Single().Id;
Expand All @@ -265,7 +265,7 @@ public async Task<ServiceCredentialBindingDetailResponse> GetServiceBindingDetai

if (response == null)
{
throw new ServiceException($"There must be exactly one service instance");
throw new ServiceException("There must be exactly one service instance", isRecoverable: true);
}

return response;
Expand Down

0 comments on commit 5b8f6cc

Please sign in to comment.