Esempio n. 1
0
        public IActionResult Index()
        {
            ElmahExtensions.RaiseError(new InvalidOperationException("This is the Test Exception from code."));

            _logger.LogTrace("Test");
            _logger.LogDebug("Test");
            _logger.LogError("Test");
            _logger.LogInformation("Test");
            _logger.LogWarning("Test");
            _logger.LogCritical(new InvalidOperationException("Test"), "Test");

            ElmahExtensions.RaiseError(new NullReferenceException());

            if (DateTime.Now.Millisecond < 500)
            {
                string str = null;
                // ReSharper disable once PossibleNullReferenceException
                foreach (var cc in str)
                {
                    Debug.WriteLine(cc);
                }
            }

            var r = 0;
            // ReSharper disable once UnusedVariable
            // ReSharper disable once IntDivisionByZero
            var d = 100 / r;

            return(View());
        }
Esempio n. 2
0
        public void RiseErrorExceptionWhenMiddlewareNotInitialised()
        {
            var         httpContext = new DefaultHttpContext();
            Func <Task> act         = async() => await ElmahExtensions.RaiseError(httpContext, new Exception());

            act.Should().ThrowAsync <MiddlewareNotInitializedException>();
        }
Esempio n. 3
0
 /// inheritDoc
 public void HandleEvent(AbpHandledExceptionData eventData)
 {
     if (eventData.Exception != null && !eventData.Exception.IsExceptionLogged())
     {
         ElmahExtensions.RiseError(eventData.Exception);
         eventData.Exception.MarkExceptionAsLogged();
     }
 }
Esempio n. 4
0
        public void RiseErrorOkWhenMiddlewareInitialized()
        {
            var         _           = new ErrorLogMiddleware(_requestDelegate, _errorLog, _loggerFactory, _options);
            var         httpContext = new DefaultHttpContext();
            Func <Task> act         = async() => await ElmahExtensions.RaiseError(httpContext, new Exception());

            act.Should().NotThrowAsync();
        }
Esempio n. 5
0
 public async Task <bool> tryCommitAsync()
 {
     try { await commitAsync(); }
     catch (Exception e)
     {
         ElmahExtensions.RiseError(e);
         new InvalidOperationException("exception", e);
         return(false);
     }
     return(true);
 }
Esempio n. 6
0
 public async Task Invoke(HttpContext context)
 {
     try
     {
         await _next.Invoke(context);
     }
     catch (Exception ex)
     {
         ElmahExtensions.RiseError(new Exception(ex.Message, ex.InnerException));
     }
 }
Esempio n. 7
0
        protected override void Append(LoggingEvent loggingEvent)
        {
            var exception = loggingEvent.ExceptionObject;

            if (exception == null || loggingEvent.ExceptionObject.IsExceptionLogged())
            {
                return;
            }

            ElmahExtensions.RiseError(exception);
        }
Esempio n. 8
0
        public void OnGet()
        {
            _logger.LogTrace("Test");
            _logger.LogDebug("Test");
            _logger.LogError("Test");
            _logger.LogInformation("Test");
            _logger.LogWarning("Test");
            _logger.LogCritical(new InvalidOperationException("Test"), "Test");

            ElmahExtensions.RaiseError(new Exception("test2"));

            var r = 0;
            // ReSharper disable once UnusedVariable
            // ReSharper disable once IntDivisionByZero
            var d = 100 / r;
        }
Esempio n. 9
0
        public IActionResult Index()
        {
            /*_logger.LogTrace("Test");
             * _logger.LogDebug("Test");
             * _logger.LogError("Test");
             * _logger.LogInformation("Test");
             * _logger.LogWarning("Test");*/
            _logger.LogCritical(new InvalidOperationException("Test"), "Test");
            ElmahExtensions.RiseError(new Exception("test2"));
            var r = 0;
            // ReSharper disable once UnusedVariable
            // ReSharper disable once IntDivisionByZero
            var d = 100 / r;

            return(View());
        }
Esempio n. 10
0
 public static void ManageExceptionContext(Exception ex)
 {
     ElmahExtensions.RiseError(ex);
 }