RMS.Common/Error/ExceptionExtend.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace RMS.Common.Error
{
public static class ExceptionExtend
{
/// <summary>
/// 获取最内层异常提示
/// </summary>
/// <param name="error">Exception异常类</param>
/// <returns></returns>
public static string GetInnerMessage(this Exception error)
{
if (error == null)
{
return string.Empty;
}
if (error.InnerException == null)
{
return error.Message;
}
return error.GetInnerMessage();
}
/// <summary>
/// 转换类型为含有Http访问信息的ErrorLog模型
/// </summary>
/// <param name="error">异常信息</param>
/// <returns></returns>
public static ErrorLog ToHttpErrorLog(this Exception error)
{
ErrorLog log = new ErrorLog();
log.ProjectName = ConfigHelper.GetAppValue("AppName", "Null");
log.Error = JsonConvert.SerializeObject(error);
log.Message = error.Message;
log.Url = HttpContext.Current.Request.Url == null ? string.Empty : HttpContext.Current.Request.Url.ToString();//错误发生地址
log.UrlReferrer = HttpContext.Current.Request.UrlReferrer == null ? string.Empty : HttpContext.Current.Request.UrlReferrer.ToString();//来源链接
log.UrlContentType = HttpContext.Current.Request.ContentType;
#region 访问参数
if (log.UrlContentType == "application/json")
{
HttpContext.Current.Request.InputStream.Position = 0;
StreamReader sr = new StreamReader(HttpContext.Current.Request.InputStream);
log.UrlParameter = sr.ReadToEnd();
}
else
{
log.UrlParameter = HttpContext.Current.Request.Form.ToString();
}
#endregion
#region 客户端IP地址
//if (!string.IsNullOrWhiteSpace(HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]))
// log.ClientIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
//else
后面还有 56 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。