public void InternalExceptionConstrucotr_WhenMessageIsCorrect_ReturnCorrectMessage()
        {
            string message = "Exception message";
              InternalException internalException = new InternalException(message);

              Assert.AreEqual(message, internalException.Message);
        }
        public void InternalExceptionConstrucotr_WhenMessageAndInnerExceptionIsCorrect_ReturnCorrectMessageAndInnerException()
        {
            string message = "Exception message";
              InvalidOperationException invalidOperationException = new InvalidOperationException();
              InternalException internalException = new InternalException(message, invalidOperationException);

              Assert.AreEqual(message, internalException.Message);
              Assert.AreEqual(invalidOperationException, internalException.InnerException);
        }
Example #3
0
        private void LogException(ActionDescriptor actionDescriptor, HttpContext httpContext, InternalException exception)
        {
            if (!ShouldExecute(actionDescriptor))
            {
                return;
            }


            if (exception.ExceptionHandled)
            {
                return;
            }

            var resultLogger = InitiateLogger(httpContext.RequestServices);
            var scopeContext = new ScopeContext();

            scopeContext.Push(AppendBaseInfoToScope(actionDescriptor, httpContext, null));
            scopeContext.Push(InternalHelper.CreateExceptionScopeContext(actionDescriptor, httpContext, exception));
            exception.ExceptionHandled = true;

            using (resultLogger.BeginScope(scopeContext.ToDictionary()))
            {
                resultLogger.LogError(exception, exception.Message);
            }
        }