正在显示
1 个修改的文件
包含
9 行增加
和
4 行删除
@@ -110,12 +110,13 @@ func (gateway BaseServiceGateway) DoRequest(requestParam Request, val interface{ | @@ -110,12 +110,13 @@ func (gateway BaseServiceGateway) DoRequest(requestParam Request, val interface{ | ||
110 | } | 110 | } |
111 | byteResult, err := req.Bytes() | 111 | byteResult, err := req.Bytes() |
112 | if err != nil { | 112 | if err != nil { |
113 | + gateway.InterceptSimple(requestParam.Url, string(byteResult), err) | ||
113 | return err | 114 | return err |
114 | } | 115 | } |
115 | var result Response | 116 | var result Response |
116 | err = json.Unmarshal(byteResult, &result) | 117 | err = json.Unmarshal(byteResult, &result) |
117 | if err != nil { | 118 | if err != nil { |
118 | - gateway.InterceptSimple(requestParam.Url, string(byteResult)) | 119 | + gateway.InterceptSimple(requestParam.Url, string(byteResult), err) |
119 | return err | 120 | return err |
120 | } | 121 | } |
121 | if result.Code != 0 && len(result.Msg) > 0 { | 122 | if result.Code != 0 && len(result.Msg) > 0 { |
@@ -124,10 +125,14 @@ func (gateway BaseServiceGateway) DoRequest(requestParam Request, val interface{ | @@ -124,10 +125,14 @@ func (gateway BaseServiceGateway) DoRequest(requestParam Request, val interface{ | ||
124 | return gateway.GetResponseData(result, val) | 125 | return gateway.GetResponseData(result, val) |
125 | } | 126 | } |
126 | 127 | ||
127 | -func (gateway BaseServiceGateway) InterceptSimple(url string, data string) { | 128 | +func (gateway BaseServiceGateway) InterceptSimple(url string, data string, err error) { |
128 | if gateway.Interceptor != nil { | 129 | if gateway.Interceptor != nil { |
129 | - gateway.Interceptor(fmt.Sprintf("【网关】 %v | %v \nResponse:%v", url, | ||
130 | - data, | 130 | + errMsg := "" |
131 | + if err != nil { | ||
132 | + errMsg = err.Error() | ||
133 | + } | ||
134 | + gateway.Interceptor(fmt.Sprintf("【网关】 %v | %v \nResponse:%v Error:%v", url, | ||
135 | + data, errMsg, | ||
131 | )) | 136 | )) |
132 | } | 137 | } |
133 | } | 138 | } |
-
请 注册 或 登录 后发表评论