< 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: 1321_24790053727
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
Fully covered methods: 0
Total methods: 1
Method coverage: 100%
Full method coverage: 0%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ToIceRpcException(...)57.69%262692.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) =>
 4015        exception.QuicError switch
 4016        {
 4017            QuicError.ConnectionAborted =>
 3318                exception.ApplicationErrorCode is long applicationErrorCode ?
 3319                    applicationErrorCode switch
 3320                    {
 3321                        (long)MultiplexedConnectionCloseError.NoError =>
 722                            new IceRpcException(IceRpcError.ConnectionClosedByPeer),
 3323                        (long)MultiplexedConnectionCloseError.Refused =>
 524                            new IceRpcException(IceRpcError.ConnectionRefused),
 3325                        (long)MultiplexedConnectionCloseError.ServerBusy =>
 626                            new IceRpcException(IceRpcError.ServerBusy),
 3327                        (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
 3334                    } :
 3335                    // An application error code should always be set with QuicError.ConnectionAborted.
 3336                    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),
 4042            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)
 4052        };
 53}