I have an async function like this:
async function testFunction() {
await doSomeWork();
const sshClient = new SSHClient();
sshClient.on('error', async error => {
throw error;
});
sshClient.connect();
}
And Im using it like this:
testFunction().then(() => {
// when an error happens in sshClient I end up here
}).catch(error => {
// and not here
});
Is there a way to catch an error which is thrown in a nested async function?