I want to throw a runtime exception in case my class invariants are invalidated. Since this is a programming error (similar to a NullPointerException), clients should not catch that exception.
Should the exception class be declared private or public (or something else)?
class Foo
{
// ...
private static class InvariantsViolated
{
// ...
}
}
Are there any guidelines on custom runtime exceptions and visibility?