forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 4
Choosing Exceptions to Raise
Jeff Tratner edited this page Jun 16, 2013
·
5 revisions
This is an opinionated (start) to a guide to using Exceptions in Pandas.
Overall: use builtin exceptions wherever possible and avoid using raise Exception
!
Again, looking at the docs on builtin exceptions is the best way to decide which to use (even includes explanations of what each sort of Exception
is meant for).
There are a number of exceptions sprinkled throughout...maybe we'll get to documenting all of them.
Try to limit PandasError
usage to cases where it
really is something specific to Pandas (like this error from pandas/core/format.py
):
# validate mi options
if self.has_mi_columns:
if cols is not None:
raise PandasError("cannot specify cols with a multi_index on the columns")