异常处理 - kuiyu/RsCode GitHub Wiki

throw new AppException("出错了");

使用步骤:

  1. 引用RsCode.AspNetCore.dll using Rs.Exceptions;

  2. 添加日志服务,在ConfigureServices services.AddLogging(); 配置log4net

  3. 配置

 services.AddMvc(
   o =>
   {             
         //o.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
         o.OutputFormatters.Insert(0, new AspNetCore.RsOutputFormatter("yyyy-MM-dd HH:mm:ss"));
   });
services.AddExceptionFilter();

 app.UseExceptionFilter(); 

配合Webapi将返回统一消息格式