We should overhaul all places and error is raised in the API. AssertionError, Exception, and RuntimeError are overused (and inappropriately used):
AssertionError is raised 47 timesException is raised 49 timesRuntimeError is raised 56 timesref https://github.com/pyvista/pyvista/pull/685#pullrequestreview-393235207
Quick reference for when to raise the common exceptions, which I think are conventional.
TypeError - When the value is of wrong type, or None if that's not expected.
ValueError - When the value is of the correct type, but wrong value.
AssertionError - Assert should really only be used in testing 99.9% of the time.
RuntimeError - Encountered an error which can not be recovered from.
IOError - Should be rarely used, maybe for a corrupt file.
FileNotFoundError - Self explanatory.
Exception - Almost never, should keep an eye out for this or bare except in try-excepts too.
Thanks for that list @JevinJ! It will be helpful to follow those guidelines when fixing this issue
@JevinJ please close this if you think we've solved this issue.
I forgot about AssertionError and RuntimeErrors, I'll close this and open a PR for the others.
Most helpful comment
I forgot about AssertionError and RuntimeErrors, I'll close this and open a PR for the others.