• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

icerpc / icerpc-csharp / 19675374127

25 Nov 2025 03:44PM UTC coverage: 83.591% (+0.05%) from 83.542%
19675374127

Pull #4166

github

web-flow
Merge 3c871e840 into 9a0d50897
Pull Request #4166: Connect_fails_if_listener_is_disposed fixes

12022 of 14382 relevant lines covered (83.59%)

2970.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.95
src/IceRpc/Transports/SocketExceptionExtensions.cs
1
// Copyright (c) ZeroC, Inc.
2

3
using System.Net.Sockets;
4

5
namespace IceRpc.Transports;
6

7
/// <summary>Provides an extension method for <see cref="SocketException"/> to convert it into an <see
8
/// cref="IceRpcException"/>.</summary>
9
public static class SocketExceptionExtensions
10
{
11
    /// <summary>Converts a <see cref="SocketException"/> into an <see cref="IceRpcException" />.</summary>
12
    /// <param name="exception">The exception to convert.</param>
13
    /// <param name="innerException">The inner exception for the <see cref="IceRpcException"/>, when
14
    /// <see langword="null"/> <paramref name="exception"/> is used as the inner exception.</param>
15
    /// <returns>The <see cref="IceRpcException"/> created from the <see cref="SocketException"/>.</returns>
16
    public static IceRpcException ToIceRpcException(this SocketException exception, Exception? innerException = null)
17
    {
333✔
18
        innerException ??= exception;
333✔
19
        IceRpcError errorCode = exception.SocketErrorCode switch
333✔
20
        {
333✔
21
            SocketError.AddressAlreadyInUse => IceRpcError.AddressInUse,
3✔
22
            SocketError.ConnectionAborted => IceRpcError.ConnectionAborted,
×
23
            // Shutdown matches EPIPE and ConnectionReset matches ECONNRESET. Both are the result of the peer closing
333✔
24
            // non-gracefully the connection. EPIPE is returned if the socket is closed and the send buffer is empty
333✔
25
            // while ECONNRESET is returned if the send buffer is not empty.
333✔
26
            SocketError.ConnectionReset => IceRpcError.ConnectionAborted,
127✔
27
            SocketError.HostUnreachable => IceRpcError.ServerUnreachable,
1✔
28
            SocketError.NetworkUnreachable => IceRpcError.ServerUnreachable,
×
29
            SocketError.Shutdown => IceRpcError.ConnectionAborted,
2✔
30
            SocketError.ConnectionRefused => IceRpcError.ConnectionRefused,
200✔
31
            SocketError.OperationAborted => IceRpcError.OperationAborted,
×
32
            _ => IceRpcError.IceRpcError
×
33
        };
333✔
34

35
        return new IceRpcException(errorCode, innerException);
333✔
36
    }
333✔
37
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc