Checked exceptions

Checked exceptions are a small topic in error handling. They’re particularly relevant to the exceptions vs error values article.

Checked exceptions act like normal exceptions except that they propagate like error values. They don’t bubble automatically. If you want them to propagate you need to propagate them manually. You have to explicitly catch them at every level and re-throw them.

However, they tend to be more disliked than error values.

One reason for this is because error values are standard values. They can be handled in all of the ways that values can be handled. Checked exceptions are more restrictive. They can only be handled in try / catch blocks.

Another reason is because checked exceptions can’t be manipulated as easily as generics in most languages. This means that you can use generics for the return error value of a function, but you may not be able to use generics for the exception.

So, they’re similar to error values, but have some additional disadvantages. For these reasons, they’re not used very often.


  • Checkmark – Photo by Malte Luk from Pexels
Notify of
Inline Feedbacks
View all comments