Esempio n. 1
0
        public async Task <IActionResult> Index(int httpStatusCode)
        {
            var exHandlerFeature = HttpContext.Features.Get <IExceptionHandlerFeature>();

            var exception = exHandlerFeature != null
                ? exHandlerFeature.Error
                : new Exception(_localizer["UnhandledException"]);

            await _exceptionNotifier.NotifyAsync(new ExceptionNotificationContext(exception));

            var errorInfo = _errorInfoConverter.Convert(exception);

            if (httpStatusCode == 0)
            {
                httpStatusCode = (int)_statusCodeFinder.GetStatusCode(HttpContext, exception);
            }

            HttpContext.Response.StatusCode = httpStatusCode;

            var page = GetErrorPageUrl(httpStatusCode);

            return(View(page, new AbpErrorViewModel
            {
                ErrorInfo = errorInfo,
                HttpStatusCode = httpStatusCode
            }));
        }
        public async Task Send_Error_Notifier_Test()
        {
            try
            {
                int x       = 10;
                int y       = 0;
                int zeroDiv = x / y;
            }
            catch (Exception ex)
            {
                await _notifier.NotifyAsync(
                    new ExceptionNotificationContext(
                        new TestSendEmailException(
                            "Test exception notufy with en", ex), LogLevel.Warning));

                using (CultureHelper.Use("zh-Hans"))
                {
                    await _notifier.NotifyAsync(
                        new ExceptionNotificationContext(
                            new TestSendEmailException(
                                "测试中文异常模板推送", ex), LogLevel.Warning));
                }
            }
        }
Esempio n. 3
0
        public static Task NotifyAsync(
            [NotNull] this IExceptionNotifier exceptionNotifier, [NotNull] Exception exception,
            LogLevel?logLevel = null,
            bool handled      = true)
        {
            Check.NotNull(exceptionNotifier, nameof(exceptionNotifier));

            return(exceptionNotifier.NotifyAsync(
                       new ExceptionNotificationContext(
                           exception,
                           logLevel,
                           handled
                           )
                       ));
        }
 protected virtual async Task HandleError(Exception exception)
 {
     Logger.LogException(exception);
     await _exceptionNotifier.NotifyAsync(exception);
 }