Skip to main content

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. 1

    Catch a rejected await

    easy10 min

    Await a rejected promise inside try and catch the error.

  2. 2

    Cover several awaits

    easy10 min

    Wrap two awaits in one try and catch the first failure.

  3. 3

    Clean up with finally

    easy10 min

    Catch the error then report that cleanup ran.

  4. 4

    Catch at the call site

    easy10 min

    Let the error escape and catch it where the function is called.

  5. 5

    Carry on after catching

    medium10 min

    Catch the failure and report a fallback value.

Find the bug(5)

  1. 1

    Fix the try that does not await

    easy8 min

    Without await the rejection escapes the try block.

  2. 2

    Fix the catch outside the async function

    easy8 min

    A plain try around the call cannot catch an async rejection.

  3. 3

    Fix the second step still running

    easy8 min

    After a failure the following awaits should be skipped.

  4. 4

    Fix the error swallowed silently

    easy8 min

    Catching without reporting hides the failure entirely.

  5. 5

    Fix finally used to handle the error

    easy8 min

    finally 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