exception hierarchy

The family tree of exception classes, with BaseException at the top and Exception above nearly every error you will catch.

In more detail

An except clause catches the named class and all its subclasses, so except Exception catches ValueError and KeyError but not KeyboardInterrupt or SystemExit, which inherit from BaseException directly. Your own exceptions should inherit from Exception.

Related terms

Taught in

References

Certification courses