Package errors
Class ErrorHandler
- java.lang.Object
-
- errors.ErrorHandler
-
public final class ErrorHandler extends java.lang.ObjectThe 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 voidadd(Error error)Adds an Error object to be stored in the ErrorHandler.booleancontainsErrors()Returns a boolean indicating whether the ErrorHandler contains any Error objects.javafx.scene.text.TextFlowgetPrimaryError()Returns a TextFlow that contains various Text objects generated from portions of the ErrorMessage.
-
-
-
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
-
-