# Extend type hints to cover exceptions

**URL:** <https://discuss.python.org/t/extend-type-hints-to-cover-exceptions/23788>\
**Category:** Typing\
**Created:** [February 11, 2023, 9:40pm UTC](https://discuss.python.org/t/extend-type-hints-to-cover-exceptions/23788 "2023-02-11T21:40:41Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![steven.daprano](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/steven.daprano/32/1083_2.png) [@steven.daprano](https://discuss.python.org/u/steven.daprano)\
**Post date:** [February 12, 2023, 1:51am UTC](https://discuss.python.org/t/extend-type-hints-to-cover-exceptions/23788/4 "2023-02-12T01:51:04Z")

</div>

Checked exceptions are widely (but not universally) recognised by the programming community as a terrible idea that causes more problems that it solves.

Very few languages have copied Java by introducing checked exceptions. Probably the most well known one is Nim, and [they recommend against using exceptions at all](https://status-im.github.io/nim-style-guide/errors.exceptions.html).

If you have never heard of Nim, consider that checked exception languages only get more obscure from there.

Popular mainstream languages influenced by Java such as C#, Scala and Koitlin have left checked exceptions out. For example, one of the C# designers [explained why](https://www.artima.com/articles/the-trouble-with-checked-exceptions).

Even in the Java community, I have never come across anyone who actively _loves_ checked exceptions, attitudes tend to vary from “well they’re not so bad, you’re just using them wrong” to dislike and worse:

- Bruce Eckel [questions whether Java needs them](https://web.archive.org/web/20180516002915/http://www.mindview.net/Etc/Discussions/CheckedExceptions).
- [“Checked exceptions were a mistake”](https://radio-weblogs.com/0122027/stories/2003/04/01/JavasCheckedExceptionsWereAMistake.html)
- [“Checked exceptions are evil”](https://phauer.com/2015/checked-exceptions-are-evil/).

I find it telling that even defenders of checked exceptions will often complain that they are hard to use and often misused. [This stackoverflow comment](https://softwareengineering.stackexchange.com/a/19231) gives Haskell as an good example of checked exceptions done right, with the minor complication that they aren’t exceptions at all. :-/

In fairness, [not everyone thinks they are an outright mistake](https://stackoverflow.com/questions/613954/the-case-against-checked-exceptions) but even the supporters acknowledge that they are very difficult to use correctly.

---

_[View the full topic](https://discuss.python.org/t/extend-type-hints-to-cover-exceptions/23788)._
