public Task OnExceptionAsync(ExceptionContext context) { // 如果异常没有被处理则进行处理 if (context.ExceptionHandled == false) { context.Result = new JsonResult(_response.Error(ResponseCode.Error, "Server Error", context.Exception)); // 设置为true,表示异常已经被处理了 context.ExceptionHandled = true; } return(Task.CompletedTask); }
public static ResponseResult Error(this IResponseService core, int userCode, string userMsg, Exception exception, object data = null) => core.Error(userCode, userMsg, exception.StackTrace, exception.Message, data);
public static ResponseResult Error(this IResponseService core, int userCode, string userMsg, string errorText, object data = null) => core.Error(userCode, userMsg, errorText, userMsg, data);