directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Karasulu" <akaras...@apache.org>
Subject Re: Constructors & Exceptions
Date Fri, 04 Jan 2008 20:22:59 GMT
Hey all check out this commit:


http://svn.apache.org/viewvc?view=rev&revision=608981


Note the commentary.  This is a special case where the NamingException
really cannot happen unless there is some drastic catastrophy with the jars
containing bootstrap schema classes and their loaders.  So in this case we
can wrap it.

Check out the commment and let me know what you think.

Alex

On Jan 4, 2008 9:41 AM, Alex Karasulu <akarasulu@apache.org> wrote:

> Hmmm I see. What about making the method that has this constructor just
> throw the exception?  If the server cannot be constructed properly it should
> be something that should interrupt what ever is trying to start it up no?
>
> Another thing is that we may not need to throw this exception.  I have a
> feeling it will never really be thrown since the bootstrap schemas are
> always packaged and will always load.  This is afterall what is now happing
> in the constructor which requires this new exception.  So I guess we can
> wrap it in an IllegalStateException since if it bombs something is messed up
> with the packaging.
>
> Alex
>
>
> On Jan 3, 2008 5:02 PM, Emmanuel Lecharny <elecharny@gmail.com> wrote:
>
> > Alex Karasulu wrote:
> > > Why is it bad to have a checked exception in the throws clause of a
> > > constructor?
> > It's not bad by essence. It just palin hurts when you have to create new
> >
> > instances in thousands places in the code :
> >
> >
> > ServerEntry entry = null;
> >
> > try
> > {
> >    entry = new DefaultServerEntry( <params> );
> > }
> > catch ( WhateverCheckedException wce )
> > {
> >    LOG.error ( "Why the HELL do I have to catch errors when creating a
> > new object everywhere ???" );
> > }
> >
> > instead of :
> > ServerEntry entry = new DefaultServerentry( <params> ); // I _know_ what
> > I'm doing !!! params *are* valid, for G*d sake !
> >
> > IMHO, of course :)
> > >
> > >
> > >     --
> > >     cordialement, regards,
> > >     Emmanuel L├ęcharny
> > >     www.iktek.com < http://www.iktek.com>
> > >     directory.apache.org <http://directory.apache.org>
> > >
> > >
> > >
> >
> >
> > --
> > --
> > cordialement, regards,
> > Emmanuel L├ęcharny
> > www.iktek.com
> > directory.apache.org
> >
> >
> >
>

Mime
View raw message