Uploaded image for project: 'OpenTrafficSim'
  1. OpenTrafficSim
  2. OTS-123

Exception.throwIf() method to separate class

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Done
    • Priority: Medium
    • Resolution: Unresolved
    • Labels:
      None

      Description

      Currently, the OTS Exception classes can report errors easily with a throwIf(condition, message, parameters) method. Disadvantage of this approach is that all OTS exception classes have to implement this method, and standard Exception classes and Exception classes from other packages cannot use the throwIf(..) method. Examples are SimRunTimeException from DSOL and NullPointerException from Java.

      The idea is to move the throwIf method to a separate class as a static method that works as follows:

      Throw.when(condition, Exception.class, string, parameters);
      

      e.g.,

      Throw.when(p == null, NullPointerException.class, "p is null");
      Throw.when(Double.isNaN(gtu.getPosition.si), GTUException.class, "position is NaN for GTU %s", gtu.getId()); 
      

        Attachments

          Activity

            People

            • Assignee:
              averbraeck Alexander Verbraeck
              Reporter:
              averbraeck Alexander Verbraeck
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:

                Time Tracking

                Estimated:
                Original Estimate - 1 hour
                1h
                Remaining:
                0m
                Logged:
                Time Not Required
                Not Specified