コード例 #1
0
 public LuccaExceptionHandlerMiddleware(RequestDelegate next, ILoggerFactory loggerFactory, IExceptionQualifier filters, IOptions <LuccaExceptionHandlerOption> options)
 {
     _next    = next;
     _filter  = filters;
     _options = options;
     _logger  = loggerFactory.CreateLogger <LuccaExceptionHandlerMiddleware>();
 }
コード例 #2
0
 public LuccaLogger(string categoryName, IHttpContextParser httpContextAccessor, Logger nloLogger, LuccaLoggerOptions options, LogExtractor logExtractor, IExceptionQualifier filters, IExceptionalWrapper exceptionalWrapper, string appName)
 {
     _categoryName       = categoryName;
     _httpContextWrapper = httpContextAccessor;
     _nloLogger          = nloLogger;
     _logExtractor       = logExtractor;
     _options            = options;
     _filters            = filters;
     _exceptionalWrapper = exceptionalWrapper;
     _appName            = appName;
 }
コード例 #3
0
        public LuccaLogsProvider(IOptionsMonitor <LuccaLoggerOptions> options, IHttpContextParser httpContextAccessor, IExceptionQualifier filters, IExceptionalWrapper exceptionalWrapper, IEnumerable <ILogDetailsExtractor> logDetailsExtractors)
        {
            _options              = options;
            _httpContextAccessor  = httpContextAccessor;
            _filters              = filters;
            _exceptionalWrapper   = exceptionalWrapper;
            _logDetailsExtractors = logDetailsExtractors;

            _changeListener = options.OnChange((o, name) =>
            {
                PropagateOptions(o);
            });

            PropagateOptions(_options.CurrentValue);
        }
コード例 #4
0
        private void Handle(ExceptionHandlerContext context)
        {
            IExceptionQualifier efilter = context.RequestContext.Configuration.DependencyResolver.GetService(typeof(IExceptionQualifier)) as IExceptionQualifier;

            if (efilter == null)
            {
                return;
            }

            string message = efilter.DisplayExceptionDetails(context.Exception) ? context.Exception.Message : efilter.GenericErrorMessage;

            context.Result = new TextPlainErrorResult
            {
                Request = context.ExceptionContext.Request,
                Content = message
            };
        }