Error handling doesn't work for throw newError() in async function
See original GitHub issueok, duplicate issue from nightwatch, becouse i don’t know who could help… how to forward my mistake to ERROR and got false in result?
throw new Error(‘some error’);
(async function () {
try {
let tmp = await kfs(title);
let staticD = tmp.leads.leadID,
getBoolean = compare(staticD, myStr);
if (getBoolean === false) {
console.log("kfs " + getBoolean);
throw new Error('some error');
}else {
console.log(`${'etalon'}`);
}
}catch (err){
console.log(err);
}
}) ()

Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
How to Throw Errors From Async Functions in JavaScript?
To recap: Throwing error from an async function won't spit out a "plain exception". Async functions and async methods always return a Promise, ......
Read more >Error handling with Async/Await in JS | by Ian Segers | ITNEXT
This works as expected, we call the function thisThrows() which throws a regular error, we catch it, log the error and optionally we...
Read more >Common Mistakes in JavaScript Async Function Error Handling
1. Error thrown from async function is a rejected promise ... For a rejected promise wrapping an uncaught error, we have two options...
Read more >Error handling with async/await and promises, n² ... - CatchJS
When an error is thrown in an async function, you can catch it with a try ... for catch() has it's own execution...
Read more >Why can't try/catch handle error throw in Promise constructor
An error inside an async function rejects the promise that the function returns. The Promise constructor doesn't do anything a promise ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’ve understood my false. Works!
@IvanNaumenko As I can see in the code example from the first post in the thread, you intentionally caught the error and logged it to the console without throwing it further. Have you tried to remove the
catchstatement from your function? 🤔