< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.ExceptionMapper
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/ExceptionMapper.cs
Line coverage
75%
Covered lines: 9
Uncovered lines: 3
Coverable lines: 12
Total lines: 76
Line coverage: 75%
Branch coverage
50%
Covered branches: 3
Total branches: 6
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor()100%11100%
FromException(...)100%11100%
FromException(...)100%11100%
HandleSecurityTokenProcessingException(...)50%6662.5%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/ExceptionMapper.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System;
 5using CoreWCF.Runtime;
 6
 7namespace CoreWCF
 8{
 9    /// <summary>
 10    /// Defines the mapping to be used for translating exceptions to faults.
 11    /// </summary>
 12    public class ExceptionMapper
 13    {
 14        internal const string SoapSenderFaultCode = "Sender";
 15
 16        /// <summary>
 17        /// ExceptionMapper constructor.
 18        /// </summary>
 5419        public ExceptionMapper()
 20        {
 5421        }
 22
 23        /// <summary>
 24        /// Translates the input exception to a fault using the mapping defined in ExceptionMap.
 25        /// </summary>
 26        /// <param name="ex">The exception to be mapped to a fault.</param>
 27        /// <returns>The fault corresponding to the input exception.</returns>
 28        public virtual FaultException FromException(Exception ex)
 29        {
 2530            return FromException(ex, string.Empty, string.Empty);
 31        }
 32
 33        /// <summary>
 34        /// Translates the input exception to a fault using the mapping defined in ExceptionMap.
 35        /// </summary>
 36        /// <param name="ex">The exception to be mapped to a fault.</param>
 37        /// <param name="soapNamespace">The SOAP Namespace to be used when generating the mapped fault.</param>
 38        /// <param name="trustNamespace">The WS-Trust Namespace to be used when generating the mapped fault.</param>
 39        /// <returns>The fault corresponding to the input exception.</returns>
 40        public virtual FaultException FromException(Exception ex, string soapNamespace, string trustNamespace)
 41        {
 2542            return null;
 43        }
 44
 45        /// <summary>
 46        /// Determines whether an exception that occurred during the processing of a security token
 47        /// should be handled using the defined ExceptionMap.
 48        /// </summary>
 49        /// <param name="ex">The input exception.</param>
 50        /// <returns>A boolean value indicating whether the exception should be handled using the defined ExceptionMap.<
 51        public virtual bool HandleSecurityTokenProcessingException(Exception ex)
 52        {
 2553            if (Fx.IsFatal(ex))
 54            {
 055                return false;
 56            }
 57
 2558            if (ex is FaultException)
 59            {
 60                // Just throw the original exception.
 061                return false;
 62            }
 63            else
 64            {
 2565                FaultException faultException = FromException(ex);
 2566                if (faultException != null)
 67                {
 068                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(faultException);
 69                }
 70
 71                // The exception is not one of the recognized exceptions. Just throw the original exception.
 2572                return false;
 73            }
 74        }
 75    }
 76}