On Wed, 2016-10-05 at 11:45 +0200, Michael Dürig wrote: > Hi, > > Throwing an IAE makes it clear that this is an error of the caller > and > not a bug in the code. However, I agree those checkArgument calls > should > include a message.
A Guava enhancement was rejected https://github.com/google/guava/issues/538 Perhaps we should something similar to Oak and use it? Robert > > Michael > > > On 5.10.16 11:38 , Robert Munteanu wrote: > > Hi, > > > > I saw the following pattern repeated in the Oak codebase: > > > > checkArgument(foo instanceOf IFoo); > > IFoo iFoo = (IFoo) foo; > > > > I am not sure that the value of the checkArgument call is. If it > > fails, > > the root cause will be an IllegalArgumentException with no message. > > On > > the other hand, if we let the ClassCastException happen, it will > > have > > an explicit message such as > > > > com.foo.NotFoo cannot be cast to com.foo.IFoo > > > > Is there a specific reason for this pattern? > > > > Thanks, > > > > Robert > >
