Latest trend is in DDD, but its by far not the first time this observation has been made. Eventually I just decided to let IllegalStateException to propagate, and just never write catch (IllegalStateException) or catch (IllegalArgumentException) . operation. We use cookies to ensure that we give you the best experience on our website. In Kotlin nulls are usually extremely to avoid, while improving the communication. Its similar in Java: in my experience, most Java static methods would be written as extensions if that was an option. IllegalArgumentException 3 /throw throws catch (trycatchfinally) TEST1calculationDublethrows ( - ) , . The "proper" use of the IllegalStateException class is somewhat subjective, since the official documentation simply states that such an exception "signals that a method has been invoked at an illegal or inappropriate time. Otherwise things like decorator pattern, delegates, and similar designs (better structure too) provide much better alternatives. Different scenarios that cause NoSuchElementException in Java. Conclusion As we've The Javadocs of IllegalStateException say. SQL Server, Oracle MySQL ? Run echo $PATH . Throwing runtime exceptions "sparingly" isn't really a good policy -- Effective Java recommends that you use checked exceptions when the caller ca field But when it comes down to things like IllegalStateException and IllegalArgumentException, they usually indicate a bug in software. One would think so, but it would just lead to unnecessary boilerplate while providing little to no value to the API user. This doesnt make any sense because the Is IllegalArgumentException a runtime exception? Run sudo nano /etc/paths. It makes slightly more complex structures harder to write, e.g., if I want a helper function it either has to be in a separate shared object (not sensible if I dont want to share it - encapsulation) or it always have to be before usage, because there is no class etc. If you read Clean Code, Effective Java, Domain Driven Design, Elegant Objects to mention a few, the same patterns of thinking will emerge. I'd say could use the ArgumentException (argument is not valid)or more specific ArgumentOutOfRangeException (argument is not in the range of valid values). Instead there are usually better design-options out there. IllegalArgumentExceptionIllegalStateException Java IllegalArgumentException throw public void regist (String name) { // if (name == null) { throw new IllegalArgumentException ( " " ); } } But as it already sounds, this is practically unfortunate to impossible to hold on in productive software development even with fancy type systems. What would be a good equivalent of this exception that does exist? , Of course there are cases where there must be state, but often subclasses/generics/interfaces can be used to present a typesafe interface that encapsulates this state in a way that the compiler can check. (Collection and Share based on the CC Protocol.). We can create our custom validator implementations in two ways - the first one is to create an annotation that confirms to the JSR-303 specs and implement its Validator class. If you call the remove() method before (or without) calling the next() method then this illegal state exception will be thrown as it will leave the List collection in an unstable state. One, users should be able to call HikariConfig.setMinimumIdle() before And even with me bringing up this argument I personally think IllegalStateException is the way to go.