protected JsonResult Error(Exception exception, HttpStatusCode statusCode = HttpStatusCode.InternalServerError) { object response = null; //解析错误 if (exception != null && exception is BusinessException) { statusCode = HttpStatusCode.BadRequest; var businessException = exception as BusinessException; response = ApiResponse <string> .BUSINESSERROR(businessException, ""); } //未知异常 else { response = ApiResponse <string> .ERROR(exception.Message, ResultCode.UNKNOW, "未知异常"); } var result = new JsonResult(response); result.StatusCode = (int)statusCode; return(result); }