1. Section Intro


Error handling is an important topic, because if your app doesn't behave correctly, then users may become frustrated, leave poor reviews, and stop using your product.

So in this section we'll cover a few different techniques that you can use to handle errors in your own apps.

We will start by covering the difference between fatal and non-fatal errors.

Then we'll revisit the approach we've taken until now, which is to:

  • throw exceptions inside our repositories or service classes whenever needed
  • and catch them inside our controllers using AsyncValue.guard
  • so that we can set some error state and show an alert to the user

After that, we will focus non non-fatal errors and create our own custom error type system, using enumssubclasses and sealed unions with Freezed.

Then we'll implement a robust error handling solution that we can use to easily log and debug fatal and non-fatal errors.

We'll design this for easy integration with external crash reporting solutions (but we'll only integrate them in the upcoming courses).

Finally, we'll talk about error handling using Result types, which is a technique that works by returning either a Success or an Error value, as an alternative to using try/catch.

Complete and Continue