IllegalStateException is a good candidate.
According to the Java API:
Signals that the method was called at an illegal or inappropriate time. In other words, the Java environment or Java application is not in the appropriate state for the requested operation.
In other words, your program is in a state for which there is no transition defined for this entry "This should not be achieved."
If your stuff , something and otherStuff are associated with method arguments, you can also use IllegalArgumentException , for example:
if (arg == null) doThings(); else if (arg.endsWith("foo")) doOtherThings(); else if (arg.endsWith("bar")) doStuff(); else throw new IllegalArgumentException( "arg should be null or end with \"foo\" or \"bar\"");
source share