< Summary

Information
Class: IceRpc.Transports.Quic.Internal.QuicExceptionExtensions
Assembly: IceRpc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Transports/Quic/Internal/QuicExceptionExtensions.cs
Tag: 592_20856082467
Line coverage
92%
Covered lines: 35
Uncovered lines: 3
Coverable lines: 38
Total lines: 53
Line coverage: 92.1%
Branch coverage
57%
Covered branches: 15
Total branches: 26
Branch coverage: 57.6%
Method coverage
100%
Covered methods: 1
Total methods: 1
Method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ToIceRpcException(...)57.69%26.332692.1%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Transports/Quic/Internal/QuicExceptionExtensions.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Net.Quic;
 4using System.Runtime.Versioning;
 5
 6namespace IceRpc.Transports.Quic.Internal;
 7
 8[SupportedOSPlatform("linux")]
 9[SupportedOSPlatform("macos")]
 10[SupportedOSPlatform("windows")]
 11internal static class QuicExceptionExtensions
 12{
 13    /// <summary>Converts a <see cref="QuicException"/> into an <see cref="IceRpcException"/>.</summary>
 14    internal static IceRpcException ToIceRpcException(this QuicException exception) =>
 3915        exception.QuicError switch
 3916        {
 3917            QuicError.ConnectionAborted =>
 3218                exception.ApplicationErrorCode is long applicationErrorCode ?
 3219                    applicationErrorCode switch
 3220                    {
 3221                        (long)MultiplexedConnectionCloseError.NoError =>
 622                            new IceRpcException(IceRpcError.ConnectionClosedByPeer),
 3223                        (long)MultiplexedConnectionCloseError.Refused =>
 524                            new IceRpcException(IceRpcError.ConnectionRefused),
 3225                        (long)MultiplexedConnectionCloseError.ServerBusy =>
 626                            new IceRpcException(IceRpcError.ServerBusy),
 3227                        (long)MultiplexedConnectionCloseError.Aborted =>
 928                            new IceRpcException(
 929                                IceRpcError.ConnectionAborted,
 930                                "The connection was aborted by the peer."),
 631                        _ => new IceRpcException(
 632                                IceRpcError.ConnectionAborted,
 633                                $"The connection was aborted by the peer with an unknown application error code: '{appli
 3234                    } :
 3235                    // An application error code should always be set with QuicError.ConnectionAborted.
 3236                    new IceRpcException(IceRpcError.IceRpcError, exception),
 037            QuicError.ConnectionRefused => new IceRpcException(IceRpcError.ConnectionRefused, exception),
 038            QuicError.ConnectionTimeout => new IceRpcException(IceRpcError.ConnectionAborted, exception),
 239            QuicError.ConnectionIdle => new IceRpcException(IceRpcError.ConnectionIdle, exception),
 340            QuicError.OperationAborted => new IceRpcException(IceRpcError.OperationAborted, exception),
 141            QuicError.AlpnInUse => new IceRpcException(IceRpcError.AddressInUse, exception),
 3942            QuicError.StreamAborted =>
 143                exception.ApplicationErrorCode is long applicationErrorCode ?
 144                    applicationErrorCode == 0 ?
 145                        new IceRpcException(IceRpcError.TruncatedData, exception) :
 146                        new IceRpcException(
 147                            IceRpcError.TruncatedData,
 148                            $"The stream was aborted by the peer with an unknown application error code: '{applicationEr
 149                    // An application error code should always be set with QuicError.StreamAborted.
 150                    new IceRpcException(IceRpcError.IceRpcError, exception),
 051            _ => new IceRpcException(IceRpcError.IceRpcError, exception)
 3952        };
 53}