У меня есть такая асинхронная функция:
async function testFunction() {
await doSomeWork();
const sshClient = new SSHClient();
sshClient.on('error', async error => {
throw error;
});
sshClient.connect();
}
И я использую это так:
testFunction().then(() => {
// when an error happens in sshClient I end up here
}).catch(error => {
// and not here
});
Есть ли способ отловить ошибку, которая выдается во вложенной асинхронной функции?