Python exceptions are classes, and as such can be sub-classed to obtain hierarchies of custom exceptions. Doing so makes it easier to handle errors in a homogeneous way, for instance in libraries. Check out the notebooks linked below for more information on Exception Handling in Python.
Embedded video, part of the following courses:
Computer Programming at Queen Mary, University of London
Jupyter notebook: https://tinyurl.com/3u76k8bf
Coding for Scientists at Queen Mary, University of London
Jupyter notebook: https://tinyurl.com/46wv5tpt
Notebooks will open on Google Colab - no installation required