Commons Lang
  1. Commons Lang
  2. LANG-212

[lang] [PATCH] New ExceptionUtils method setCause()

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.2
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: Other

      Description

      Hi people,

      the purpose of the ExceptionUtils.setCause() method I am proposing is to
      preserve the standard JDK 1.4 exception

      nesting mechanism even when targeting source code for a prior JDK 1.4 version.

      ExceptionUtils.setCause(), which can be thought as the counterpart of
      ExceptionUtils.getCause(), calls via

      introspection on the target Throwable the 2 following methods:

      <Object>.setCause(Throwable)
      <Object>.initCause(Throwable)

      The typical use of ExceptionUtils.setCause() is inside a constructor, as in
      the following example:

      import org.apache.commons.lang.exception.ExceptionUtils;

      public class MyException extends Exception {

      public MyException(String msg)

      { super(msg); }

      public MyException(String msg, Throwable cause)

      { super(msg); ExceptionUtils.setCause(this, cause); }

      }

      I hope this can be useful for whom who are maintaining code that must be
      portable on both the JDK 1.3 and JDK 1.4+

      environments.

      Andrea.

        Activity

        Henri Yandell made changes -
        Affects Version/s Nightly Builds [ 12311718 ]
        Mark Thomas made changes -
        Workflow jira [ 12371630 ] Default workflow, editable Closed status [ 12601976 ]
        Henri Yandell made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Henri Yandell made changes -
        Fix Version/s 2.2 [ 12311702 ]
        Henri Yandell made changes -
        Affects Version/s 1.4 Final [ 12311903 ]
        Henri Yandell made changes -
        Fix Version/s 2.2 [ 12311686 ]
        Key COM-2573 LANG-212
        Assignee Jakarta Commons Developers Mailing List [ commons-dev@jakarta.apache.org ]
        Affects Version/s 1.4 Final [ 12311663 ]
        Component/s Lang [ 12311121 ]
        Project Commons [ 12310458 ] Commons Lang [ 12310481 ]
        Henri Yandell made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 37574 12342725
        Andrea Rombaldi created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Andrea Rombaldi
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development