< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Dispatcher.ExceptionHandler
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/ExceptionHandler.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 12
Coverable lines: 12
Total lines: 57
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
HandleException(...)100%110%
.ctor(...)100%110%
HandleException(...)100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/ExceptionHandler.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.Dispatcher
 8{
 9    public abstract class ExceptionHandler
 10    {
 011        public static ExceptionHandler AlwaysHandle { get; } = new AlwaysHandleExceptionHandler();
 12
 13        public static ExceptionHandler AsynchronousThreadExceptionHandler
 14        {
 15            get
 16            {
 017                HandlerWrapper wrapper = (HandlerWrapper)Fx.AsynchronousThreadExceptionHandler;
 018                return wrapper?.Handler;
 19            }
 20
 21            set
 22            {
 023                Fx.AsynchronousThreadExceptionHandler = value == null ? null : new HandlerWrapper(value);
 024            }
 25        }
 26
 027        public static ExceptionHandler TransportExceptionHandler { get; set; } = AlwaysHandle;
 28
 29        // Returns true if the exception has been handled.  If it returns false or
 30        // throws a different exception, the original exception will be rethrown.
 31        public abstract bool HandleException(Exception exception);
 32
 33        private class AlwaysHandleExceptionHandler : ExceptionHandler
 34        {
 35            public override bool HandleException(Exception exception)
 36            {
 037                return true;
 38            }
 39        }
 40
 41        private class HandlerWrapper : Fx.ExceptionHandler
 42        {
 043            public HandlerWrapper(ExceptionHandler handler)
 44            {
 45                Fx.Assert(handler != null, "Cannot wrap a null handler.");
 046                Handler = handler;
 047            }
 48
 049            public ExceptionHandler Handler { get; }
 50
 51            public override bool HandleException(Exception exception)
 52            {
 053                return Handler.HandleException(exception);
 54            }
 55        }
 56    }
 57}