< Summary

Information
Class: IceRpc.DispatchException
Assembly: IceRpc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/DispatchException.cs
Tag: 275_13775359185
Line coverage
100%
Covered lines: 7
Uncovered lines: 0
Coverable lines: 7
Total lines: 38
Line coverage: 100%
Branch coverage
75%
Covered branches: 3
Total branches: 4
Branch coverage: 75%
Method coverage
100%
Covered methods: 3
Total methods: 3
Method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_ConvertToInternalError()100%11100%
get_StatusCode()100%11100%
.ctor(...)75%44100%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/DispatchException.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3namespace IceRpc;
 4
 5/// <summary>Represents an exception thrown while dispatching a request. It's encoded as a response with a status code
 6/// greater than <see cref="StatusCode.Ok" />.</summary>
 7public sealed class DispatchException : Exception
 8{
 9    /// <summary>Gets or sets a value indicating whether the exception should be converted into a <see
 10    /// cref="DispatchException" /> with status code <see cref="StatusCode.InternalError" /> when thrown from a
 11    /// dispatch.</summary>
 12    /// <value>When <see langword="true" />, this exception is converted into dispatch exception with status code <see
 13    /// cref="StatusCode.InternalError" /> just before it's encoded. Defaults to <see langword="true" /> for an
 14    /// exception decoded from an <see cref="IncomingResponse" />, and <see langword="false" /> for an exception created
 15    /// by the application using a constructor of <see cref="DispatchException" />.</value>
 5916    public bool ConvertToInternalError { get; set; }
 17
 18    /// <summary>Gets the status code.</summary>
 19    /// <value>The <see cref="IceRpc.StatusCode" /> of this exception.</value>
 4720    public StatusCode StatusCode { get; }
 21
 22    /// <summary>Constructs a new instance of <see cref="DispatchException" />.</summary>
 23    /// <param name="statusCode">The status code of this exception. It must be greater than <see
 24    /// cref="StatusCode.Ok" />.</param>
 25    /// <param name="message">A message that describes the exception.</param>
 26    /// <param name="innerException">The exception that is the cause of the current exception.</param>
 27    /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="statusCode" /> is equal to <see
 28    /// cref="StatusCode.Ok" />.</exception>
 29    public DispatchException(
 30        StatusCode statusCode,
 31        string? message = null,
 32        Exception? innerException = null)
 5533        : base(message ?? $"The dispatch failed with status code {statusCode}.", innerException) =>
 5534        StatusCode = statusCode > StatusCode.Ok ? statusCode :
 5535            throw new ArgumentOutOfRangeException(
 5536                nameof(statusCode),
 5537                $"The status code of a {nameof(DispatchException)} must be greater than {nameof(StatusCode.Ok)}.");
 38}