完善服务异常时的返回结果
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
李寻欢 2021-09-09 10:59:05 +08:00
parent ce1b5546eb
commit 4fe735ce0d
2 changed files with 5 additions and 2 deletions

View File

@ -49,6 +49,7 @@ func (n nacosClient) Remote(ctx *gin.Context) {
})
if err != nil {
Log.Error("获取健康服务失败: %v\n", err.Error())
ctx.String(http.StatusBadGateway, "服务异常: %v", err.Error())
return
}
// 组装内部接口
@ -57,6 +58,7 @@ func (n nacosClient) Remote(ctx *gin.Context) {
req, err := http.NewRequest(ctx.Request.Method, apiUrl, ctx.Request.Body)
if err != nil {
Log.Error("请求异常: %v\n", err)
ctx.String(http.StatusBadGateway, "请求异常: %v", err.Error())
return
}
// 填充Form参数(大概率用不上)
@ -72,6 +74,7 @@ func (n nacosClient) Remote(ctx *gin.Context) {
response, err := client.Do(req)
if err != nil {
Log.Error("请求异常: %v\n", err)
ctx.String(http.StatusBadGateway, "请求异常:%v", err.Error())
return
}
// 返回结果到前端

View File

@ -66,10 +66,10 @@ func NewJaegerTracer() (opentracing.Tracer, io.Closer) {
tracer, closer, err := cfg.NewTracer()
if err != nil {
core.Log.Error("Jaeger连接失败: %v", err.Error())
//core.Log.Error("Jaeger连接失败: %v", err.Error())
return nil, nil
}
core.Log.Debug("Jaeger连接成功")
//core.Log.Debug("Jaeger连接成功")
opentracing.SetGlobalTracer(tracer)
return tracer, closer
}