For what it's worth, when I write my own code these days, I use either
NullPointerException("variable-name") or IllegalArgumentException("why
it's illegal")On 8/3/07, Andrus Adamchik <[EMAIL PROTECTED]> wrote: > > On Aug 3, 2007, at 7:18 PM, Kevin Menard wrote: > > > I imagine throwing > > CayenneException is preferred, but given that it's a checked > > exception, > > that could mean rewriting interfaces. > > We certainly DO NOT want every method in Cayenne to throw checked > exceptions. Then it will be as "usable" as JDBC :-) > CayenneRuntimeException (and its two specialized subclasses - > ExpressionException and EJBQLException) and IllegalArgumentException > are two of my favorites. > > For things like argument checking in the user-facing API, > IllegalArgumentException seems more appropriate than > CayenneRuntimeException. > > Also I don't think we have too many methods in Cayenne (if any at > all) that throw checked CayenneException, requiring a try/catch. It > is always CayenneRuntimeException. > > > I'm a fan of throwing unchecked exceptions if we can't do anything > > about the problem anyway. > > Yep. > > > Also, should we be adding tests to check the exceptions are actually > > thrown and pair them up with fail() calls? Or, has the approach > > been to > > just introduce the exception and just make sure the existing test > > suite > > passes? > > It's been the later. But also because everybody wants to cut down > time writing unit tests, not because of some principle :-) > > Andrus > > >
