classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches]: Patch: JPasswordField


From: Mark Wielaard
Subject: Re: [cp-patches]: Patch: JPasswordField
Date: Wed, 24 Aug 2005 20:00:51 +0200

Hi,

On Wed, 2005-08-24 at 13:10 -0400, Lillian Angel wrote:
> > Are you sure you want to return the empty string if there is a
> > BadLocationException thrown from the underlying code? It looks like that
> > might hide problems with the Document (sub) class implementation. Better
> > would be to chain it in a InternalError() and throw that since it seems
> > that BadLocationException should never be thrown when getText() is
> > called like this.
> 
> I handled this the same way JTextComponent does.
> 
>     try
>       {
>       return doc.getText(0, doc.getLength());
>       }
>     catch (BadLocationException e)
>       {
>       // This should never happen.
>       return "";
>       }
>   }
> 
> I think it makes most sense to return an empty string. 

To be honest I think that if something should never happen then we
should throw an InternalError (with the original exception as cause).
Returning something in that case just hides a real problem.

Cheers,

Mark

-- 
Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html

Join the community at http://planet.classpath.org/

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]