Mobile development

Stage 1 · Lesson 8 of 9

Errors in sync and async code

JavaScript and TypeScript

Wrap awaited calls, the ones built on , in try and catch. Use finally for clean-up such as hiding a spinner, whatever happened. Throw Error objects rather than strings, so you keep a showing where it failed.

In the caught value has the type unknown until you check it. Know which failures do not throw at all. fetch finishes normally for a 404 or 500 error from the server, so you must check response.ok yourself.

Catch errors where the app can react, such as showing a retry button, not inside every helper.

Common trapan empty catch that swallows the error, leaving a blank screen and nothing in the logs.

A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

  • CoursePaid
    Grokking JavaScript Fundamentals

    Design Gurus · Beginner · $50

    Beginner JavaScript with an exercise after most lessons

  • GuideFree
    JavaScript.info

    Ilya Kantor

    Free and thorough: Part 1 is the language, skip the browser chapters in Part 2

Practise

  • Dart, TypeScript, Kotlin and Swift tracks with small exercises and free mentor feedback

Keep handy

Also worth your time

Mark this stage as not done?