Torque
  1. Torque
  2. TORQUE-148

remove throws clause in setter for referenced object by a foreign key

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.0-beta1
    • Component/s: None
    • Labels:
      None

      Description

      for the schema
      <table name="book" description="Book table">
      ....
      <foreign-key foreignTable="author">
      <reference local="author_id" foreign="author_id"/>
      </foreign-key>
      </table>

      Torque generates (complexObjectModel=true) in BaseBook:

      public void setAuthor(Author v) throws TorqueException
      {
      if (v == null)

      { setAuthorId(0); }

      else

      { setAuthorId(v.getAuthorId()); }

      aAuthor = v;
      }

      the TorqueException in the throws clause of the method is never thrown and should be removed.

        Activity

        Hide
        Thomas Fox added a comment -

        In this special case no runtime Exception is needed. It will never be thrown.

        If we want to change the Torque exception handling in a global manner we should first discuss on the dev list and then open another jira issue. Personally I like checked exceptions as long as the exception hierarchy makes sense. But IMO this is a matter of taste.

        Show
        Thomas Fox added a comment - In this special case no runtime Exception is needed. It will never be thrown. If we want to change the Torque exception handling in a global manner we should first discuss on the dev list and then open another jira issue. Personally I like checked exceptions as long as the exception hierarchy makes sense. But IMO this is a matter of taste.
        Hide
        CG Monroe added a comment -

        As has been said in the dev list, exception handling is a beast. I think a good solution would be to replace this with TorqueRuntimeException.

        The reason being is that this make re-writing code that currently has to handle TorqueExceptions easier. Just change the exception type. Plus it simplifies future code by removing the exception handing requirement because Runtime Exceptions don't get flagged by compiler.

        Show
        CG Monroe added a comment - As has been said in the dev list, exception handling is a beast. I think a good solution would be to replace this with TorqueRuntimeException. The reason being is that this make re-writing code that currently has to handle TorqueExceptions easier. Just change the exception type. Plus it simplifies future code by removing the exception handing requirement because Runtime Exceptions don't get flagged by compiler.

          People

          • Assignee:
            Thomas Fox
            Reporter:
            Thomas Fox
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development