重构代码:异常模块增加异常类型显示

This commit is contained in:
Argo-MacBookPro 2018-09-28 09:09:09 +08:00
parent d86fe3e7b7
commit 43796875af
2 changed files with 3 additions and 2 deletions

View File

@ -15,7 +15,8 @@
{ title: "请求网址", field: "ErrorPage", sortable: true },
{ title: "用户名", field: "UserId", sortable: true },
{ title: "IP", field: "UserIp", sortable: true },
{ title: "错误", field: "Message", sortable: false },
{ title: "异常类型", field: "ExceptionType", sortable: false },
{ title: "异常描述", field: "Message", sortable: false },
{ title: "记录时间", field: "LogTime", sortable: true }
]
});

View File

@ -29,7 +29,7 @@ namespace Bootstrap.DataAccess
/// <returns></returns>
public static void Log(Exception ex, NameValueCollection additionalInfo)
{
var errorPage = additionalInfo["ErrorPage"] ?? (ex.Message.Length > 50 ? ex.Message.Substring(0, 50) : ex.Message);
var errorPage = additionalInfo["ErrorPage"] ?? (nameof(ex).Length > 50 ? nameof(ex).Substring(0, 50) : nameof(ex));
var sql = "insert into Exceptions (AppDomainName, ErrorPage, UserID, UserIp, ExceptionType, Message, StackTrace, LogTime) values (@AppDomainName, @ErrorPage, @UserID, @UserIp, @ExceptionType, @Message, @StackTrace, GetDate())";
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{