Package errors

Class ErrorHandler


  • public final class ErrorHandler
    extends java.lang.Object
    The ErrorHandler class is used to store Error objects that have been generated during compilation.

    As compilation proceeds errors may occur, which results in the creation of Error objects. These are passed to an instance of ErrorHandler and stored within an internal LinkedList, from which the initial Error can be retrieved.

    Since:
    1.0
    • Constructor Summary

      Constructors 
      Constructor Description
      ErrorHandler​(SourceInput sourceInput)
      Constructs an ErrorHandler object for storing Errors that occur during compilation.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(Error error)
      Adds an Error object to be stored in the ErrorHandler.
      boolean containsErrors()
      Returns a boolean indicating whether the ErrorHandler contains any Error objects.
      javafx.scene.text.TextFlow getPrimaryError()
      Returns a TextFlow that contains various Text objects generated from portions of the ErrorMessage.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ErrorHandler

        public ErrorHandler​(SourceInput sourceInput)
        Constructs an ErrorHandler object for storing Errors that occur during compilation.

        Requires the initial compilation input so that errors can be located in the text.

        A LinkedList is initialised on construction for storing the Error objects.

        Parameters:
        sourceInput - The source code input which is being compiled
    • Method Detail

      • add

        public void add​(Error error)
        Adds an Error object to be stored in the ErrorHandler.
        Parameters:
        error - The Error object to be stored
      • containsErrors

        public boolean containsErrors()
        Returns a boolean indicating whether the ErrorHandler contains any Error objects.

        If true, the ErrorHandler contains at least one Error. If false, the ErrorHandler contains no errors.

        Returns:
        A boolean indicating if the ErrorHandler contain any errors
      • getPrimaryError

        public javafx.scene.text.TextFlow getPrimaryError()
        Returns a TextFlow that contains various Text objects generated from portions of the ErrorMessage.

        Only the first Error that the ErrorHandler received is returned. All other Errors are discarded, since they are most likely false-positives that have only occurred as a result of the first Error being present.

        Returns:
        The TextFlow containing Text objects with information about the error