Package org.codehaus.groovy.syntax

# Class SyntaxException

java.lang.Object
java.lang.Throwable
java.lang.Exception
org.codehaus.groovy.GroovyException
org.codehaus.groovy.syntax.SyntaxException

All Implemented Interfaces:
  `Serializable`, `GroovyExceptionInterface`

Direct Known Subclasses:
  `IncorrectTypeHintException`, `TokenException`

public class SyntaxException extends GroovyException
Base exception class indicating a syntax error detected during parsing. Captures source location information (line and column numbers) where the error occurred to facilitate debugging and error reporting.

See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SyntaxException(String message, int startLine, int startColumn)`
  Constructs a SyntaxException with line and column information.
  `SyntaxException(String message, int startLine, int startColumn, int endLine, int endColumn)`
  Constructs a SyntaxException with complete position range information.
  `SyntaxException(String message, Throwable cause, int startLine, int startColumn)`
  Constructs a SyntaxException with a cause exception.
  `SyntaxException(String message, Throwable cause, int startLine, int startColumn, int endLine, int endColumn)`
  Constructs a SyntaxException with a cause exception and complete position information.
  `SyntaxException(String message, ASTNode node)`
  Constructs a SyntaxException from an AST node's position information.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getEndColumn()`
  Returns the ending column number of the error.
  `int`
  `getEndLine()`
  Returns the ending line number of the error.
  `int`
  `getLine()`
  Returns the starting line number of the error.
  `String`
  `getMessage()`
  Returns the error message with location information appended.
  `String`
  `getOriginalMessage()`
  Returns the original error message without location information.
  `String`
  `getSourceLocator()`
  Returns the optional source locator string.
  `int`
  `getStartColumn()`
  Returns the starting column number of the error.
  `int`
  `getStartLine()`
  Returns the starting line number of the error.
  `void`
  `setSourceLocator(String sourceLocator)`
  Sets an optional source locator string (e.g., file path, URL).

  ### Methods inherited from class org.codehaus.groovy.GroovyException

  `isFatal, setFatal`

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

  `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, 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`

- ## Constructor Details

  - ### SyntaxException

    public SyntaxException(String message, ASTNode node)
    Constructs a SyntaxException from an AST node's position information.
    Parameters:
      `message` - the error message
      `node` - the `ASTNode` where the error occurred

  - ### SyntaxException

    public SyntaxException(String message, int startLine, int startColumn)
    Constructs a SyntaxException with line and column information. The end position defaults to one column after the start position.
    Parameters:
      `message` - the error message
      `startLine` - the line number where the error starts (1-based)
      `startColumn` - the column number where the error starts (1-based)

  - ### SyntaxException

    public SyntaxException(String message, int startLine, int startColumn, int endLine, int endColumn)
    Constructs a SyntaxException with complete position range information.
    Parameters:
      `message` - the error message
      `startLine` - the line number where the error starts (1-based)
      `startColumn` - the column number where the error starts (1-based)
      `endLine` - the line number where the error ends (1-based)
      `endColumn` - the column number where the error ends (1-based)

  - ### SyntaxException

    public SyntaxException(String message, Throwable cause, int startLine, int startColumn)
    Constructs a SyntaxException with a cause exception. The end position defaults to one column after the start position.
    Parameters:
      `message` - the error message
      `cause` - the underlying `Throwable` that caused this exception
      `startLine` - the line number where the error starts (1-based)
      `startColumn` - the column number where the error starts (1-based)

  - ### SyntaxException

    public SyntaxException(String message, Throwable cause, int startLine, int startColumn, int endLine, int endColumn)
    Constructs a SyntaxException with a cause exception and complete position information.
    Parameters:
      `message` - the error message
      `cause` - the underlying `Throwable` that caused this exception
      `startLine` - the line number where the error starts (1-based)
      `startColumn` - the column number where the error starts (1-based)
      `endLine` - the line number where the error ends (1-based)
      `endColumn` - the column number where the error ends (1-based)

- ## Method Details

  - ### setSourceLocator

    public void setSourceLocator(String sourceLocator)
    Sets an optional source locator string (e.g., file path, URL).
    Parameters:
      `sourceLocator` - the source location identifier

  - ### getSourceLocator

    public String getSourceLocator()
    Returns the optional source locator string.
    Returns:
      the source location identifier, or `null` if not set

  - ### getLine

    public int getLine()
    Returns the starting line number of the error. Provided for backward compatibility; equivalent to `getStartLine()`.
    Returns:
      the line number (1-based)

  - ### getStartLine

    public int getStartLine()
    Returns the starting line number of the error.
    Returns:
      the line number (1-based)

  - ### getStartColumn

    public int getStartColumn()
    Returns the starting column number of the error.
    Returns:
      the column number (1-based)

  - ### getEndLine

    public int getEndLine()
    Returns the ending line number of the error.
    Returns:
      the line number (1-based)

  - ### getEndColumn

    public int getEndColumn()
    Returns the ending column number of the error.
    Returns:
      the column number (1-based)

  - ### getOriginalMessage

    public String getOriginalMessage()
    Returns the original error message without location information.
    Returns:
      the base error message

  - ### getMessage

    public String getMessage()
    Returns the error message with location information appended.
    Overrides:
      `getMessage` in class `Throwable`
    Returns:
      the formatted message including line and column information