diff --git a/src/Docker.DotNet/Endpoints/DockerSwarmNodeAlreadyParticipatingException.cs b/src/Docker.DotNet/Endpoints/DockerSwarmNodeAlreadyParticipatingException.cs new file mode 100644 index 00000000..0b6e76d4 --- /dev/null +++ b/src/Docker.DotNet/Endpoints/DockerSwarmNodeAlreadyParticipatingException.cs @@ -0,0 +1,9 @@ +namespace Docker.DotNet; + +public class DockerSwarmNodeAlreadyParticipatingException : DockerApiException +{ + public DockerSwarmNodeAlreadyParticipatingException(HttpStatusCode statusCode, string? responseBody) + : base(statusCode, responseBody) + { + } +} \ No newline at end of file diff --git a/src/Docker.DotNet/Endpoints/DockerSwarmNodeNotParticipatingException.cs b/src/Docker.DotNet/Endpoints/DockerSwarmNodeNotParticipatingException.cs new file mode 100644 index 00000000..678dc60b --- /dev/null +++ b/src/Docker.DotNet/Endpoints/DockerSwarmNodeNotParticipatingException.cs @@ -0,0 +1,9 @@ +namespace Docker.DotNet; + +public class DockerSwarmNodeNotParticipatingException : DockerApiException +{ + public DockerSwarmNodeNotParticipatingException(HttpStatusCode statusCode, string? responseBody) + : base(statusCode, responseBody) + { + } +} \ No newline at end of file diff --git a/src/Docker.DotNet/Endpoints/SwarmOperations.cs b/src/Docker.DotNet/Endpoints/SwarmOperations.cs index 8609a63e..6ff57d85 100644 --- a/src/Docker.DotNet/Endpoints/SwarmOperations.cs +++ b/src/Docker.DotNet/Endpoints/SwarmOperations.cs @@ -6,8 +6,7 @@ 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); } }; @@ -15,8 +14,7 @@ internal class SwarmOperations : ISwarmOperations { if (statusCode == HttpStatusCode.ServiceUnavailable) { - // TODO: Make typed error. - throw new Exception("Node is already part of a swarm."); + throw new DockerSwarmNodeAlreadyParticipatingException(statusCode, responseBody); } }; diff --git a/test/Docker.DotNet.Tests/TestFixture.cs b/test/Docker.DotNet.Tests/TestFixture.cs index 8005b89b..9f3c7280 100644 --- a/test/Docker.DotNet.Tests/TestFixture.cs +++ b/test/Docker.DotNet.Tests/TestFixture.cs @@ -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.");