修复ErrorModule中间件中logger因为formatter为空
xxred 编写于 2019-02-13 20:28:36
NewLife.Cube
@model System.Web.Mvc.HandleErrorInfo
@{
    //Layout = "_Ace_Layout.cshtml";
    Layout = "_Layout.cshtml";
    //Layout = NewLife.Cube.Setting.Current.Layout;
    ViewBag.Title = "处理你的请求时出错";

    var ex = Model == null ? null : Model.Exception;

    var error = "没有捕捉到异常信息";
    var context = ViewBag.Context as ExceptionContext;
    if (context != null && context.Exception != null)
    {
        // 由于nginx的配置导致出现奇葩错误
        ex = context.Exception;
    }
    if (NewLife.Cube.Setting.Current.Debug)
    {
        error = ex.ToString();
    }
    else
    {
        error = ex.GetTrue().Message;
    }
    error = error.Replace("--->", "--->" + Environment.NewLine);
}
<div class="panel panel-default">
    <div class="panel-body">
        <strong>
            <pre class="alert alert-danger" role="alert">@error</pre>
        </strong>
    </div>
    <div class="panel-footer">
        <a href="javascript: history.go(-1);" class="btn btn-info">返回上一页</a>
    </div>
</div>