Linking the exceptions is a good idea as it preserves the original
stack trace. What could cause this Exception is hard to guess but
a wrong paramter string is more likely than a broken Java installation
thus IllegalArgument probably fits better.

bye,

-christian-


Am Sat, 1 Sep 2012 11:27:51 -0400
schrieb Gary Gregory <[email protected]>:

> There is a nice bit of (IMO) ugliness in
> org.apache.commons.codec.digest.DigestUtils.getDigest(String):
> 
>     public static MessageDigest getDigest(String algorithm) {
>         try {
>             return MessageDigest.getInstance(algorithm);
>         } catch (NoSuchAlgorithmException e) {
>             throw new RuntimeException(e.getMessage());
>         }
>     }
> 
> Throwing a RuntimeException and not even linking the exception
> combine for two no-nos.
> 
> I propose:
> 
>             throw new IllegalArgumentException(e);
> 
> In theory, this would break someone looking for a DigestUtils
> throwing a RuntimeException.
> 
> At the very least we should do:
> 
>             // ugly
>             throw new RuntimeException(e);
> 
> Thoughts?
> 
> E-Mail: [email protected] | [email protected]
> JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
> Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to