问题描述
我正在尝试实现错误处理,以防 nodegit 克隆失败,根据文档,只有对承诺的解决,但不能拒绝(然后不捕获) https://www.nodegit.org/api/clone/
我尝试过使用 try{} catch(e){} 但 catch 没有捕捉到错误。 我也试过 .catch 但它没有被调用。
任何想法我如何知道是否发生错误?
测试我在克隆请求中注入的错误处理实现和错误(在安装toek中添加了硬编码1:
return Git.Clone("https://x-access-token:" + `${installation_token}1` + "@github.com/" + full_repo_name + ".git",repository).then(function (repo) {
console.log('Repo clone done!')
repo.getCommit(Git.Oid.fromString(ref)).then(function (commit) {
console.log('Get commit done!')
Git.Checkout.tree(repo,commit).then(function () {
console.log('Checkout done!')
return true
}).catch(e => {throw("Coult no clone repository,error 1 : ",e)})
}).catch(e => {throw("Coult no clone repository,error 2 : ",e)})
}).catch(e => {throw("Coult no clone repository,error 3 : ",e)})
process.chdir(pwd)
}catch(e) {
console.log('clone repo Failed catched')
{throw("Coult no clone repository,error 4 : ",e)}
}
这是我的日志:
2021-02-21T18:16:37.013971+00:00 app[web.1]:克隆存储库 2021-02-21T18:16:37.093216+00:00 app[web.1]: 错误(事件):需要远程身份验证但未设置回调 2021-02-21T18:16:37.093218+00:00 app[web.1]:错误:需要远程身份验证但未设置回调
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)