优化非debug模式用户不可见错误提示

This commit is contained in:
孟帅
2023-05-11 15:53:51 +08:00
parent e873204a87
commit f7c8092aee
4 changed files with 25 additions and 4 deletions

View File

@@ -104,11 +104,13 @@ func responseJson(r *ghttp.Request) {
g.Log().Warningf(ctx, "exception:%v", err)
code = gerror.Code(err).Code()
message = err.Error()
// 是否输出错误到页面
if g.Cfg().MustGet(ctx, "hotgo.debug", true).Bool() {
message = err.Error()
data = charset.ParseErrStack(err)
} else {
message = consts.ErrorMessage(err)
}
} else {
data = r.GetHandlerResponse()

View File

@@ -197,7 +197,7 @@ func (s *sSysLog) AnalysisLog(ctx context.Context) entity.SysLog {
ipData, err := location.GetLocation(ctx, clientIp)
if err != nil {
g.Log().Infof(ctx, "location.GetLocation clientIp:%v, err:%+v", clientIp, err)
g.Log().Debugf(ctx, "location.GetLocation clientIp:%v, err:%+v", clientIp, err)
}
if ipData == nil {

View File

@@ -31,7 +31,7 @@ func (s *sCronClient) Start(ctx context.Context) {
return
}
if config.Client == nil || config.Client.Cron == nil {
if config == nil || config.Client == nil || config.Client.Cron == nil {
g.Log().Errorf(ctx, "CronClient config is invalid")
return
}