All async functions should be wrapped in try/catch blocks
Arthurmtro opened this issue · comments
ex:
const test = async () => {
try {
const res = await Promise.resolve(...)
throw(...error...)
} catch (e) {
...
}
}
nwscript-sinfar-language-server/server/src/Documents/Document.ts
Lines 43 to 70 in c5afa54
This will probably require a pretty significant reworking of the code since async functions require their calling functions to also be async which causes almost every function to end up being async (Except the top-level functions). I definitely understand the value of it though because a lot of the issues I run into is async functions failing. They don't seem to throw exceptions normally from what I've seen. Instead, the code just fails silently. Will that cause those exceptions to be caught reliably?
Yeah using catch will get rid of the crashs as you will handle them. Plus you will understand better how to clean your code base