Mark Wielaard wrote:
> Sent: Thursday, August 18, 2005 22:57
> To: Roman Kennke
> Cc: Classpath-Patches
> Subject: Re: [cp-patches] FYI: Made PixelGrabber more robust
> 
> Hi,
> 
> On Thu, 2005-08-18 at 15:41 +0200, Roman Kennke wrote:
> >             public void run ()
> >             {
> > -             ip.startProduction (PixelGrabber.this);
> > +              try
> > +                {
> > +                  ip.startProduction (PixelGrabber.this);
> > +                }
> > +              catch (Exception ex)
> > +                {
> > +                  ex.printStackTrace();
> > +                  imageComplete(ImageConsumer.ABORTED);
> > +                }
> >             }
> >           };
> 
> Why catch Exception and not Throwable? (You will miss notifying the
> consumer when an Error is thrown). Why print the stack trace?

IMO, the proper way to handle this is a pattern like this:

boolean ok = false;
try
  {
    ip.startProduction(PixelGrabber.this);
    ok = true;
  }
finally
  {
    if (!ok)
      imageComplete(ImageConsumer.ABORTED);
  }

That way you never swallow the exception (so that it can bubble up to
the unhandled exception handler for the thread/threadgroup.

Regards,
Jeroen


_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to