Skip to content

Commit

Permalink
优化api请求的错误收集
Browse files Browse the repository at this point in the history
  • Loading branch information
zhigang.li committed Nov 20, 2018
1 parent 8552ce1 commit 6106e50
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/libs/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ class HttpRequest {
return { data, status }
}, error => {
this.destroy(url)
addErrorLog(error.response)
let errorInfo = error.response
if (!errorInfo) {
const { request: { statusText, status }, config } = JSON.parse(JSON.stringify(error))
errorInfo = {
statusText,
status,
request: { responseURL: config.url }
}
}
addErrorLog(errorInfo)
return Promise.reject(error)
})
}
Expand Down

0 comments on commit 6106e50

Please sign in to comment.