java - What is the best runtime exception to use when mandatory input is missing -
i have service, simple class need take input , run business logic. before executing service, user must set data. in general, this:
public class testservice extends innerservicebase { /** * mandatory input */ private object inputobj; @override protected errorcode executeimpl() { //some business logic on inputobj return null; } public void setinputobj(object inputobj) { this.inputobj = inputobj; } } what best runtime exception throw in case inputobj null ?
illegalstateexception seems best fit. object not in correct state have executeimpl() called on it. whatever exception use, make sure error message helpful.
whether should using unchecked exception @ whole other question...
Comments
Post a Comment