fix(promise): handle rejection elegantly

This commit is contained in:
kevinhwang91 2022-09-20 12:45:09 +08:00
parent f0ae3c77d9
commit c01e3d81ef
4 changed files with 4 additions and 4 deletions

View file

@ -21,7 +21,7 @@ exports.activate = async context => {
if (!languages.hasProvider('foldingRange', textDocument)) {
await wait(500)
if (!languages.hasProvider('foldingRange', textDocument)) {
throw new Error('UfoFallbackException')
throw 'UfoFallbackException'
}
}
await doc.synchronize()

View file

@ -110,7 +110,7 @@ function Fold.update(bufnr)
if not dispose(false) then
return
end
error(err)
promise.reject(err)
end)
end

View file

@ -45,7 +45,7 @@ function Provider:requestFoldingRange(providers, bufnr)
return {main, nil}
end
else
error(reason)
return promise.reject(reason)
end
end)
if log.isEnabled('debug') then

View file

@ -7,7 +7,7 @@
"main": "coc-extension/index.js",
"type": "commonjs",
"engines": {
"coc": "^0.0.81"
"coc": "^0.0.82"
},
"activationEvents": [
"*"