What exception to throw when an important parameter/dependency is missing?

I'd use IllegalArgumentException if the parameter/argument is controlled from outside, or IllegalStateException if the method is just called at a wrong moment (state). In your specific case I think it's the latter. A (dubious) alternative is NullPointerException.

This should however be explicitly documented in the @throws so that the user understands the reason.


How about IllegalStateException?


I would use an IllegalStateException because the id is state of the owner. If the id would have passed as parameter, an IllegalArgumentException would be right.