Uploaded image for project: 'Struts 1'
  1. Struts 1
  2. STR-2437

Standardize exception rethrows to contain root cause

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.1.1, 1.2.9, 1.3.8
    • 1.4.0
    • None
    • Operating System: All
      Platform: All
    • 34604

    Description

      It would be exceptionally helpful if the Struts project were to standardize
      throughout development that all caught exceptions that are to be re-thrown
      should contain the root cause unless a clearly stated, specific reason exists to
      not do so.

      For example, in org.apache.struts.taglib.tiles.InsertTag on any Exception within
      doEngTag(), the following occurs:

      catch (ServletException e) {
      Throwable cause = e;
      if (e.getRootCause() != null)

      { cause = e.getRootCause(); }

      String msg = "ServletException in '" + page + "': " + cause.getMessage();
      log.error(msg, e);
      throw new JspException(msg);
      }

      It would be rather simple to do the following for the last line:

      throw new JspException(msg, e);

      While the root exception message is logged, this information is not available to
      an upper-level application layer. For example, if a custom SecurityException is
      thrown on a JSP or Tag, important information may be lost in the propogation of
      this exception.

      I have looked within the 1.2.6 beta codebase (as of today, 25 April 2005) and
      the approach remains the same.

      Note: I did not choose the "Tiles Framework" for this report's Component
      purposefully. In my opinion, it should be a standard coding procedure across
      Struts, and possibly other Jakarta projects.

      Attachments

        Issue Links

          Activity

            People

              pbenedict Paul Benedict
              lukas@somnia.com Lukas Bradley
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: