using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Hncore.Pass.Manage.Filters
{
    /// <summary>
    /// 全局异常过滤器(主要是发生异常后写日志)
    /// </summary>
    ///
    public class HttpGlobalExceptionFilter : IExceptionFilter
    {
        /// <summary>
        /// 日志工厂对象
        /// </summary>
        readonly ILoggerFactory _loggerFactory;
        /// <summary>
        /// 主机环境对象
        /// </summary>
        readonly IHostingEnvironment _env;

        public HttpGlobalExceptionFilter(ILoggerFactory loggerFactory, IHostingEnvironment env)
        {
            _loggerFactory = loggerFactory;
            _env = env;
        }

        public void OnException(ExceptionContext context)
        {
            throw  context.Exception;
        }
    }
}
