Is there any reason to throw a DivideByZeroException?
- by Atomiton
Are there any cases when it's a good idea to throw errors that can be avoided?
I'm thinking specifically of the DivideByZeroException and NullReferenceException
For example:
double numerator = 10;
double denominator = getDenominatorFromUser();
if( denominator == 0 ){
throw new DivideByZeroException("You can't divide by Zero!");
}
Are there any reasons for throwing an error like this?
NOTE: I'm not talking about catching these errors, but specifically in knowing if there are ever good reasons for throwing them.