Package errors

Class Error

  • Direct Known Subclasses:
    LexicalError, SemanticError, SyntaxError

    public abstract class Error
    extends java.lang.Object
    The Error class is an abstract class used to represent errors that occur during compilation.

    Children classes of Error call the parent constructor when initialised, and the majority of object generation is performed here, which stores information about the error that occurred.

    Since:
    1.0
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Error.ErrorMessage
      The ErrorMessage class is used to store information about an error.
    • Constructor Summary

      Constructors 
      Constructor Description
      Error​(ErrorType errorType, SourceSpan span, java.lang.String problem, java.lang.String solution)
      Constructs an Error object for storing information about an error that occurred during compilation.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Error.ErrorMessage getErrorMessage​(SourceInput sourceInput)
      Returns an ErrorMessage object, containing formatted information about the error that occurred.
      • Methods inherited from class java.lang.Object

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

      • Error

        public Error​(ErrorType errorType,
                     SourceSpan span,
                     java.lang.String problem,
                     java.lang.String solution)
        Constructs an Error object for storing information about an error that occurred during compilation.

        To generate an Error, it is required to provide a description of the problem and a solution. These must be clear, detailed, and jargon-free. The type of error and location in the text must also be provided.

        Parameters:
        errorType - The type of error, which is based on where in the compilation process it occurred
        span - The location in the text that the error occurred
        problem - A description of the problem which caused the error
        solution - A description of a possible solution to solve the error
    • Method Detail

      • getErrorMessage

        public Error.ErrorMessage getErrorMessage​(SourceInput sourceInput)
        Returns an ErrorMessage object, containing formatted information about the error that occurred.

        The same SourceInput object used during compilation is required in order to identify and visualised where in the text the error occurred.

        Parameters:
        sourceInput - The original SourceInput used during compilation
        Returns:
        An ErrorMessage object containing information about the error