Introduction

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

In the previous lesson, you saw that defining a function that throws doesn’t enable the compiler to provide as much coding assistance as you’d like.

  • To switch over the cases of a specific Error type, you must cast error as that type.
  • Or, you must specify the type of Error for each catch closure, even if the throwing function throws only one type of Error.
  • And you must always catch any other errors, even when you know the throwing functions never throw any other type of Error.

Learning Objectives

In this lesson, you’ll see how typed throws overcome these issues, to help the compiler help you. You’ll learn:

See forum comments
Download course materials from Github
Previous: Conclusion Next: Typed Throws