Suppose our task is to implement a class A solving a certain task. And this class should not throw exceptions simply because such is the nature of the problem it is solving.
But class A uses an auxiliary class B, to which you can submit incorrect parameters. On the one hand, it would be good in this case to throw an exception, making it easier to follow debugging, but on the other hand, no one except us will use this class and waste machine time on unnecessary checks.
To be such an exception or not to be?
The question concerns only languages that do not support debug / release code selection (ifdef in C ++).
An exaggerated example : a console program in which we enter a square of a square and get the length of its side. Moreover, the input area is filtered so that the user can not enter an incorrect value. Is it necessary in the sqrt function, which for some reason we have written ourselves, to make a check for the negativeness of the argument and throw an exception in this case?
If you write this check, it will be easier to catch the internal errors of the programmer, but in the release version the check will be superfluous.