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)) { if (!languages.hasProvider('foldingRange', textDocument)) {
await wait(500) await wait(500)
if (!languages.hasProvider('foldingRange', textDocument)) { if (!languages.hasProvider('foldingRange', textDocument)) {
throw new Error('UfoFallbackException') throw 'UfoFallbackException'
} }
} }
await doc.synchronize() await doc.synchronize()

View file

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

View file

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

View file

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