using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Utility.Entity;
namespace Utility
{
public class CustomerExceptionFilter : IAsyncExceptionFilter
{
///
/// 重写OnExceptionAsync方法,定义自己的处理逻辑
///
///
///
private readonly ILogger _logger;
public CustomerExceptionFilter(ILogger logger)
{
_logger = logger;
}
public Task OnExceptionAsync(ExceptionContext context)
{
// 如果异常没有被处理则进行处理
if (context.ExceptionHandled == false)
{
//var result = "系统异常,请联系管理员";
//if (context.Exception is AppFriendlyException)
var result = context.Exception.Message;
var apiResponse = new ApiResponse