Reputation: 437
I'm working on a API which for the most part a wrapper around NumPy. In some cases, the wrapper method just calls a NumPy method and returns what the NumPy method returns.
I those cases, what is better practice, should the wrapper methods validate arguments and raise error or should they should pass the arguments to NumPy and let NumPy raise the exception?
Upvotes: 0
Views: 65
Reputation: 480
when called methods, Immediately check the arguments.
However, if you only use the function internally, you do not need to raise an error.
It is a bad habit to use a lot of things that cause errors.
Upvotes: 0
Reputation: 314
If your API has additional requirements for input validation then it is appropriate to raise exceptions, otherwise you could just let the input be passed to NumPy and have NumPy raise the input validation exceptions.
Upvotes: 1