In my opinion, it's best to trap the error as soon as possible.   As
far as I remember, that's our standard practice, and as we come across
items like this, we correct them.


On 8/3/07, Kevin Menard <[EMAIL PROTECTED]> wrote:
> I know this has come up before and some debate goes on and then no
> decision is really made.  Do we want to improve exception reporting?
>
> I've always found this to be a weak point in Cayenne's game.
> Fortunately, I've become more comfortable with loading up the source
> code and stepping through things to see what's wrong, but it's normally
> debugging time that could largely be saved.  The root problem, I think,
> is that where a failure actually occurs and where a failure are
> introduced are normally far apart.
>
> As a minimal example, I tried to create likeIgnoreCaseExp(), but passed
> in null for the value.  I received the following NPE:
>
> Caused by: java.lang.NullPointerException
>         at
> org.apache.cayenne.exp.parser.SimpleNode.connectChildren(SimpleNode.java
> :276)
>         at
> org.apache.cayenne.exp.parser.ASTLikeIgnoreCase.<init>(ASTLikeIgnoreCase
> .java:43)
>         at
> org.apache.cayenne.exp.ExpressionFactory.likeIgnoreCaseExp(ExpressionFac
> tory.java:529)
>         at
> com.servprise.www.pages.store.CheckOut.addCoupon(CheckOut.java:291)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> a:39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> Impl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at
> org.apache.tapestry.listener.ListenerMethodInvokerImpl.invokeTargetMetho
> d(ListenerMethodInvokerImpl.java:214)
>         at
> org.apache.tapestry.listener.ListenerMethodInvokerImpl.invokeListenerMet
> hod(ListenerMethodInvokerImpl.java:155)
>         ... 51 more
>
> Now, had I not had the source loaded in Eclipse already, it would have
> been awfully difficult to track down.  Tapestry loading on its own
> exception stuff doesn't help much.
>
> On the other hand, if an IllegalArgumentException had been thrown in
> likeIgnoreCaseExp indicating that value must not be null, my debugging
> time would have been cut down considerably.  I have run across many
> similar situations in the past couple years.
>
> If anyone has any thoughts on the matter, please chime in.  It is
> something I would like to see move forward with the 3.0 release.
>
> --
> Kevin Menard
> Servprise International, Inc.
> 800.832.3823 x308
>

Reply via email to