wx.request报错区分超时和错误码上报
Showing
1 changed file
with
14 additions
and
2 deletions
@@ -152,9 +152,15 @@ function request(method = 'GET') { | @@ -152,9 +152,15 @@ function request(method = 'GET') { | ||
152 | } | 152 | } |
153 | }, | 153 | }, |
154 | fail: function (err) { | 154 | fail: function (err) { |
155 | + const ERROR_TYPE = { | ||
156 | + ['request:fail']: 'NETWORK_API_CODE_ERR', | ||
157 | + ['request:fail timeout']: 'NETWORK_API_TIMEOUT' | ||
158 | + }; | ||
159 | + const errType = ERROR_TYPE[err && err.errMsg || ''] || ''; | ||
160 | + | ||
155 | appReport({ | 161 | appReport({ |
156 | pt: 'NETWORK', | 162 | pt: 'NETWORK', |
157 | - pn: 'NETWORK_API_CODE_ERR', | 163 | + pn: errType, |
158 | param: { | 164 | param: { |
159 | url: url, | 165 | url: url, |
160 | st: JSON.stringify(err || {}) | 166 | st: JSON.stringify(err || {}) |
@@ -252,9 +258,15 @@ function request(method = 'GET') { | @@ -252,9 +258,15 @@ function request(method = 'GET') { | ||
252 | } | 258 | } |
253 | }, | 259 | }, |
254 | fail: function (err) { | 260 | fail: function (err) { |
261 | + const ERROR_TYPE = { | ||
262 | + ['request:fail']: 'NETWORK_API_CODE_ERR', | ||
263 | + ['request:fail timeout']: 'NETWORK_API_TIMEOUT' | ||
264 | + }; | ||
265 | + const errType = ERROR_TYPE[err && err.errMsg || ''] || ''; | ||
266 | + | ||
255 | appReport({ | 267 | appReport({ |
256 | pt: 'NETWORK', | 268 | pt: 'NETWORK', |
257 | - pn: 'NETWORK_API_CODE_ERR', | 269 | + pn: errType, |
258 | param: { | 270 | param: { |
259 | url: url, | 271 | url: url, |
260 | st: JSON.stringify(err || {}) | 272 | st: JSON.stringify(err || {}) |
-
Please register or login to post a comment