我有一个包含这两个包的 Go 项目:
loggingconfig,因为我想将当前配置发送到我的错误报告系统configlogging,因为我想记录程序是否无法打开配置文件解决此依赖性错误的最佳实践是什么?
我正在 axios 中使用拦截器来检查错误。
service.interceptors.response.use(
response => response,
error => {
const originalRequest = error.config
if (!error.response) {
// No network connectivity
}
}
)
Run Code Online (Sandbox Code Playgroud)
我的请求看起来像这样
service.post('endpoint').then(response => {
// Successful request
}).catch(error => {
// Handle error
})
Run Code Online (Sandbox Code Playgroud)
如果出现任何错误,例如不成功的状态代码(例如 400),我不想处理catch第二个代码示例部分中的错误。但是,如果存在网络问题,我不想处理第一个代码示例中的错误。在这种情况下,不应调用第二个代码示例的 、then或。catch我怎样才能实现这个目标?