Class ParseException

All Implemented Interfaces:
Serializable

public class ParseException extends Exception
The parse exception contains necessary information to understand the parse failure.
See Also:
  • Constructor Details

    • ParseException

      public ParseException(ParseErrorCode ec, String text, int line, int column, String source)
      Construct a parse exception.
      Parameters:
      ec - The error code.
      text - The line on which the parse failed.
      line - The line number.
      column - The column.
      source - Information about where the xmq originated from.
    • ParseException

      public ParseException(ParseErrorCode ec, String text, int line, int column, String source, String info, int char_index)
      Construct a parse exception with extra information, like the C error_info, where the offending char is not at the column (as in the yaml parser).
      Parameters:
      ec - The error code.
      text - The line on which the parse failed.
      line - The line number.
      column - The column that is reported.
      source - Information about where the xmq originated from.
      info - Extra information appended to the message, or null.
      char_index - The position of the offending char in text, -1 if at the end of the input.
    • ParseException

      public ParseException(ParseErrorCode ec, String text, int line, int column, String source, int caret_bytes, int code_point, ParseException warning)
      Construct a parse exception of the xmq parser, printed like the C generate_state_error_message: the line of the input (at most 1024 bytes) with the ^ after as many spaces as there are utf8 bytes before the error.
      Parameters:
      ec - The error code.
      text - The line of the input around the error.
      line - The line number.
      column - The column, in characters (code points).
      source - Information about where the xmq originated from.
      caret_bytes - The number of utf8 bytes of the line before the error, -1 when the error is at the end of the input (the line is not shown).
      code_point - The character at the error, 0 at the end of the input.
      warning - A warning printed before the error, or null.
  • Method Details

    • cStyle

      public boolean cStyle()
      Is this exception printed like generate_state_error_message in C.
      Returns:
      true if it is
    • caretBytes

      public int caretBytes()
      Get the number of utf8 bytes before the ^, -1 if the line is not shown.
      Returns:
      the number of bytes
    • codePoint

      public int codePoint()
      Get the character at the error, 0 at the end of the input.
      Returns:
      the code point
    • warning

      public ParseException warning()
      Get the warning printed before the error, or null.
      Returns:
      the warning
    • info

      public String info()
      Get the extra information, or null.
      Returns:
      the information
    • charIndex

      public int charIndex()
      Get the position of the offending char in the text, -1 if at the end of the input.
      Returns:
      the position
    • errorCode

      public ParseErrorCode errorCode()
      Get the error code.
      Returns:
      error code
    • text

      public String text()
      Get the line of text.
      Returns:
      line of text
    • line

      public int line()
      Get the line number.
      Returns:
      line number
    • column

      public int column()
      Get the column.
      Returns:
      column
    • source

      public String source()
      Get the source, ie file name, "mbuffer", "stdin" etc.
      Returns:
      The source information.