Bad Data and Bad Behavior

Learn about the specialized exceptions for handling loading errors and enhancing user authorization.

What can go wrong?

It helps to consider what can go wrong when loading a Sample object, and what–if anything–the user can do about it. Our sample validation rules suggest we may want to raise specialized kinds of ValueError exceptions to describe data, where the measurements aren’t valid float values or the species name, isn’t one of the known strings.

We can use a class like the following to define the condition of bad data that can’t be processed:

Get hands-on with 1200+ tech skills courses.