`error` vs `throw(ArgumentError(...))`


Hi guys!

I just want to know the best practice here. In my package, if I see an error related to an wrong input argument (like using -1 for orbit eccentricity), then is it better to use error ou throw(ArgumentError(...)) to the user? I asked on slack but I got mixed results.


I would use ArgumentError or DomainError. Being more specific is just informative to the user (as neither of these errors would be something that you would routinely catch). Cf


Being more specific also allows you to write tests with @test_throws that don’t just pass spuriously if the same type of error is thrown in some other part of the code under test.


Excellent arguments! Thanks guys, I will change all the errors to some more informative.