The <stdexcept> defines a pair of standard exceptions. However, I have problems determining when to use which exception. Are there any good recommendations you can find online? I will try to illustrate my problem with an example:
The function takes the length of the (physical) vector and the angle (between 0 and pi) to return a new vector. If the angle is negative, then
- A
std::invalid_argument , since negative angles are not valid? - A
std::logic_error , since negative angles do not make sense in this case? - A
std::out_of_range , since negative angles are outside the allowed range for angles? - A
std::domain_error , because the mathematical function is not defined at negative angles. - Or should I define a custom exception?
(In case someone wonders: I'm trying to convert the coordinates into a triclinic simulation box, which are actually three lengths and three angles - see here if you are interested.)
source share