JavaScript async Error Handling — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript async Error Handling lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Catch a rejected await
easy10 minAwait a rejected promise inside try and catch the error.
- 2
Cover several awaits
easy10 minWrap two awaits in one try and catch the first failure.
- 3
Clean up with finally
easy10 minCatch the error then report that cleanup ran.
- 4
Catch at the call site
easy10 minLet the error escape and catch it where the function is called.
- 5
Carry on after catching
medium10 minCatch the failure and report a fallback value.
Find the bug(5)
- 1
Fix the try that does not await
easy8 minWithout await the rejection escapes the try block.
- 2
Fix the catch outside the async function
easy8 minA plain try around the call cannot catch an async rejection.
- 3
Fix the second step still running
easy8 minAfter a failure the following awaits should be skipped.
- 4
Fix the error swallowed silently
easy8 minCatching without reporting hides the failure entirely.
- 5
Fix finally used to handle the error
easy8 minfinally always runs but does not catch anything.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace