edu.northwestern.at.utils

## Class InvalidDataException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - edu.northwestern.at.utils.InvalidDataException

- All Implemented Interfaces:
    java.io.Serializable

      public class InvalidDataException
      extends java.lang.Exception

  Exception for reporting invalid data input.

  An InvalidDataException can be thrown as an exception in the usual way, e.g.,

  `throw new InvalidDataException( "Your imput data is invalid" );`

  However, an instance of InvalidDataException can also be used to collect a list of input data errors. You can throw the existing InvalidDataException at this point and the detailed messages will be available to the code which catches the error.

  Example:

        InvalidDataException ide    = new InvalidDataException();
        lineNumber = 0;

        ...
        // If an input line has a data error, add a descriptive message to ide

        ide.addMessage( "Invalid input in line " + lineNumber );
        ...

        if ( ide.hasMessages() )
        {
            throw ide;
        }

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.List<java.lang.String>` | `errorMessages` List to hold error messages.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `InvalidDataException()` Create empty data exception.
    `InvalidDataException(java.lang.String description)` Create data exception with error description.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addMessage(java.lang.String errorMessage)` Add error message to list of errors.
    `java.util.List<java.lang.String>` | `getMessages()` Get list of error messages.
    `boolean` | `hasMessages()` Check there are any error messages.

    - ### Methods inherited from class java.lang.Throwable

      `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### errorMessages

          protected java.util.List<java.lang.String> errorMessages

      List to hold error messages.

  - ### Constructor Detail

    - #### InvalidDataException

          public InvalidDataException()

      Create empty data exception.

    - #### InvalidDataException

          public InvalidDataException(java.lang.String description)

      Create data exception with error description.
      Parameters:
        `description` - Description of error.

  - ### Method Detail

    - #### addMessage

          public void addMessage(java.lang.String errorMessage)

      Add error message to list of errors.
      Parameters:
        `errorMessage` - The message to add to the list.

    - #### getMessages

          public java.util.List<java.lang.String> getMessages()

      Get list of error messages.
      Returns:
        Error messages as unmodifiable list.

    - #### hasMessages

          public boolean hasMessages()

      Check there are any error messages.
      Returns:
        true if there are any error messages.