Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #8404

Re: Thumbs up for suppressable exceptions in JDK 1.7

From Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Thumbs up for suppressable exceptions in JDK 1.7
Date 2011-09-29 23:57 +0200
Organization A noiseless patient Spider
Message-ID <j62pmk$4gp$1@dont-email.me> (permalink)
References <j5ru3o$cu7$1@news.albasani.net> <cp5387dadnj2jmuheklm82niu718054nsj@4ax.com> <alpine.DEB.2.00.1109272034540.14737@urchin.earth.li> <j6252f$etv$1@dont-email.me> <XK2hq.1$eF7.0@newsfe20.iad>

Show all headers | View raw


On 29/09/2011 20:25, Daniel Pitts allegedly wrote:
> I want to read up on it, but I wonder if it will help with this
> (unfortunate) situation:
> 
> try {
>    buggyCodeThrowsNullPointerException();
> } catch (Exception oopsThisWasIgnoredByLazyProgrammer) {
>    throw new BusinessLayerSpecificException(
>         "Unable to process request for no good reason.");
> }
> 
> This suppresses a bug, but the original programmer wasn't thinking about
> potential bugs, only recoverable exceptions.  The exception is
> effectively suppressed.

Probably won't help that situation.

The suppressed exception mechanism addresses a structural short-coming
of the Java core libraries. If at any point you were confronted with two
Throwables (and their respective stack of causes), and planned to throw
something, you had no choice but to decide to drop one of the two.

The situation you're describing here is not a structural problem, it's
bad code. Language changes can sometimes facilitate good code or the
opposite, but they're not a solution to bad code. The only guaranteed
safeguard against bad coding is not coding at all.

In other words, while the structural problem could be addressed by a
change in the language/libraries, I don't think the one of bad code can.

-- 
DF.
Determinism trumps correctness.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Thumbs up for suppressable exceptions in JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-09-27 09:31 +0200
  Re: Thumbs up for suppressable exceptions in JDK 1.7 Roedy Green <see_website@mindprod.com.invalid> - 2011-09-27 02:28 -0700
    Re: Thumbs up for suppressable exceptions in JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-09-27 11:38 +0200
    Re: Thumbs up for suppressable exceptions in JDK 1.7 Tom Anderson <twic@urchin.earth.li> - 2011-09-27 20:43 +0100
      Re: Thumbs up for suppressable exceptions in JDK 1.7 Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-09-29 18:05 +0200
        Re: Thumbs up for suppressable exceptions in JDK 1.7 Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-09-29 11:25 -0700
          Re: Thumbs up for suppressable exceptions in JDK 1.7 Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-09-29 23:57 +0200
          Re: Thumbs up for suppressable exceptions in JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-09-30 11:30 +0200
        Re: Thumbs up for suppressable exceptions in JDK 1.7 Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-09-29 18:57 -0300
  Re: Thumbs up for suppressable exceptions in JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-10-02 13:38 +0200
    Re: Thumbs up for suppressable exceptions in JDK 1.7 Jan Burse <janburse@fastmail.fm> - 2011-10-02 13:45 +0200
      Re: Thumbs up for suppressable exceptions in JDK 1.7 Tom Anderson <twic@urchin.earth.li> - 2011-10-03 19:08 +0100

csiph-web