classpath
[Top][All Lists]
Advanced

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

Re: Informative throws


From: Stuart Ballard
Subject: Re: Informative throws
Date: Thu, 26 Jul 2001 14:30:24 -0400

Tom Tromey wrote:
> 
> Eric>     if (str == null || (len = str.length()) == 0)
> Eric>       if (Configuration.EXCEPTION_MESSAGES)
> Eric>         throw new NumberFormatException("string null or empty");
> Eric>       else
> Eric>         throw new NumberFormatException();
> 
> My concerns with this approach are maintainability and readability.  I
> wish it were easily possible to do this via some sort of preprocessing
> step.

There's always:

throw Configuration.EXCEPTION_MESSAGES ?
      new NumberFormatException("string null or empty") :
      new NumberFormatException();

This is, I think, slightly more readable - although I've always been a
fan of the ternary operator, so I'm biased perhaps.

Stuart.



reply via email to

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