Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Docker.DotNet;

public class DockerSwarmNodeAlreadyParticipatingException : DockerApiException
{
public DockerSwarmNodeAlreadyParticipatingException(HttpStatusCode statusCode, string? responseBody)
: base(statusCode, responseBody)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Docker.DotNet;

public class DockerSwarmNodeNotParticipatingException : DockerApiException
{
public DockerSwarmNodeNotParticipatingException(HttpStatusCode statusCode, string? responseBody)
: base(statusCode, responseBody)
{
}
}
6 changes: 2 additions & 4 deletions src/Docker.DotNet/Endpoints/SwarmOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ internal class SwarmOperations : ISwarmOperations
{
if (statusCode == HttpStatusCode.ServiceUnavailable)
{
// TODO: Make typed error.
throw new Exception("Node is not part of a swarm.");
throw new DockerSwarmNodeNotParticipatingException(statusCode, responseBody);
}
};

private static readonly ApiResponseErrorHandlingDelegate AlreadyInSwarmResponseHandler = (statusCode, responseBody) =>
{
if (statusCode == HttpStatusCode.ServiceUnavailable)
{
// TODO: Make typed error.
throw new Exception("Node is already part of a swarm.");
throw new DockerSwarmNodeAlreadyParticipatingException(statusCode, responseBody);
}
};

Expand Down
2 changes: 1 addition & 1 deletion test/Docker.DotNet.Tests/TestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ await DockerClient.Images.CreateImageAsync(new ImagesCreateParameters { FromImag

_hasInitializedSwarm = true;
}
catch
catch (DockerSwarmNodeAlreadyParticipatingException)
{
this.LogInformation("Couldn't init a new swarm, the node should take part of an existing one.");

Expand Down
Loading