diff --git a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java index 1b251218a..9ea769a62 100644 --- a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java +++ b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java @@ -814,20 +814,22 @@ public class ExceptionUtils { } /** - * Use to throw a checked exception without adding the exception to the throws + * Throws the given (usually checked) exception without adding the exception to the throws * clause of the calling method. This method prevents throws clause - * pollution and reduces the clutter of "Caused by" exceptions in the + * inflation and reduces the clutter of "Caused by" exceptions in the * stack trace. *
- * The use of this technique may be controversial, but exceedingly useful to - * library developers. + * The use of this technique may be controversial, but useful. *
*- * public int propagateExample { // note that there is no throws clause + * // There is no throws clause in the method signature. + * public int propagateExample() { * try { - * return invocation(); // throws IOException - * } catch (Exception e) { - * return ExceptionUtils.rethrow(e); // propagates a checked exception + * // throws SomeCheckedException. + * return invocation(); + * } catch (SomeCheckedException e) { + * // Propagates a checked exception and compiles to return an int. + * return ExceptionUtils.rethrow(e); * } * } *@@ -836,15 +838,19 @@ public class ExceptionUtils { * checked exception in a RuntimeException: * *
- * public int wrapExample { // note that there is no throws clause + * // There is no throws clause in the method signature. + * public int wrapExample() { * try { - * return invocation(); // throws IOException + * // throws IOException. + * return invocation(); * } catch (Error e) { * throw e; * } catch (RuntimeException e) { - * throw e; // wraps a checked exception + * // Throws an unchecked exception. + * throw e; * } catch (Exception e) { - * throw new UndeclaredThrowableException(e); // wraps a checked exception + * // wraps a checked exception. + * throw new UndeclaredThrowableException(e); * } * } *@@ -863,8 +869,8 @@ public class ExceptionUtils { * * @param throwable * The throwable to rethrow. - * @param