Overview | Package | Class
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.control
Class ErrorCollector

A base class for collecting messages and errors during processing. Each CompilationUnit should have one and SourceUnits should share their ErrorCollector with the CompilationUnit.

author:
  Chris Poirier

author:
  Jochen Theodorou

version:
  $Id: ErrorCollector.java 6778 2007-07-02 10:40:33Z glaforge $

Field Summary
`CompilerConfiguration` | `configuration`
`LinkedList` | `errors`
`LinkedList` | `warnings`

Constructor Summary
`ErrorCollector(CompilerConfiguration configuration)` WarningMessages collected during processing

Method Summary
`void` | `addCollectorContents(ErrorCollector er)`
`void` | `addError(Message message)` Adds a non-fatal error to the message set.
`void` | `addError(Message message, boolean fatal)` Adds an optionally-fatal error to the message set.
`void` | `addError(SyntaxException error, SourceUnit source)` Convenience wrapper for addError().
`void` | `addError(String text, CSTNode context, SourceUnit source)` Convenience wrapper for addError().
`void` | `addErrorAndContinue(Message message)` Adds an error to the message set, but don't fail.
`void` | `addException(Exception cause, SourceUnit source)`
`void` | `addFatalError(Message message)` Adds a fatal exception to the message set and throws the unit as a PhaseFailedException.
`void` | `addWarning(WarningMessage message)` Adds a WarningMessage to the message set.
`void` | `addWarning(int importance, String text, CSTNode context, SourceUnit source)` Convenience wrapper for addWarning() that won't create an object unless it is relevant.
`void` | `addWarning(int importance, String text, Object data, CSTNode context, SourceUnit source)` Convenience wrapper for addWarning() that won't create an object unless it is relevant.
`void` | `failIfErrors()` Causes the current phase to fail by throwing a CompilationFailedException.
`Message` | `getError(int index)` Returns the specified error message, or null.
`int` | `getErrorCount()` Returns the number of errors.
`List` | `getErrors()` Returns the list of errors, or null if there are none.
`Exception` | `getException(int index)` Convenience routine to return the specified error's underlying Exception, or null if it isn't one.
`Message` | `getLastError()` Returns the last error reported
`SyntaxException` | `getSyntaxError(int index)` Convenience routine to return the specified error's underlying SyntaxException, or null if it isn't one.
`WarningMessage` | `getWarning(int index)` Returns the specified warning message, or null.
`int` | `getWarningCount()` Returns the number of warnings.
`List` | `getWarnings()` Returns the list of warnings, or null if there are none.
`boolean` | `hasErrors()` Returns true if there are any errors pending.
`boolean` | `hasWarnings()` Returns true if there are any warnings pending.
`void` | `write(PrintWriter writer, Janitor janitor, List messages, String txt)`
`void` | `write(PrintWriter writer, Janitor janitor)` Writes error messages to the specified PrintWriter.

Constructor Detail

### ErrorCollector

    public ErrorCollector(CompilerConfiguration configuration)

  WarningMessages collected during processing

Method Detail

### addCollectorContents

    public void addCollectorContents(ErrorCollector er)

### addError

    public void addError(Message message)

  Adds a non-fatal error to the message set.

### addError

    public void addError(Message message, boolean fatal)

  Adds an optionally-fatal error to the message set. Throws the unit as a PhaseFailedException, if the error is fatal.

### addError

    public void addError(SyntaxException error, SourceUnit source)

  Convenience wrapper for addError().

### addError

    public void addError(String text, CSTNode context, SourceUnit source)

  Convenience wrapper for addError().

### addErrorAndContinue

    public void addErrorAndContinue(Message message)

  Adds an error to the message set, but don't fail.

### addException

    public void addException(Exception cause, SourceUnit source)

### addFatalError

    public void addFatalError(Message message)

  Adds a fatal exception to the message set and throws the unit as a PhaseFailedException.

### addWarning

    public void addWarning(WarningMessage message)

  Adds a WarningMessage to the message set.

### addWarning

    public void addWarning(int importance, String text, CSTNode context, SourceUnit source)

  Convenience wrapper for addWarning() that won't create an object unless it is relevant.

### addWarning

    public void addWarning(int importance, String text, Object data, CSTNode context, SourceUnit source)

  Convenience wrapper for addWarning() that won't create an object unless it is relevant.

### failIfErrors

    void failIfErrors()

  Causes the current phase to fail by throwing a CompilationFailedException.

### getError

    public Message getError(int index)

  Returns the specified error message, or null.

### getErrorCount

    public int getErrorCount()

  Returns the number of errors.

### getErrors

    public List getErrors()

  Returns the list of errors, or null if there are none.

### getException

    public Exception getException(int index)

  Convenience routine to return the specified error's underlying Exception, or null if it isn't one.

### getLastError

    public Message getLastError()

  Returns the last error reported

### getSyntaxError

    public SyntaxException getSyntaxError(int index)

  Convenience routine to return the specified error's underlying SyntaxException, or null if it isn't one.

### getWarning

    public WarningMessage getWarning(int index)

  Returns the specified warning message, or null.

### getWarningCount

    public int getWarningCount()

  Returns the number of warnings.

### getWarnings

    public List getWarnings()

  Returns the list of warnings, or null if there are none.

### hasErrors

    public boolean hasErrors()

  Returns true if there are any errors pending.

### hasWarnings

    public boolean hasWarnings()

  Returns true if there are any warnings pending.

### write

    void write(PrintWriter writer, Janitor janitor, List messages, String txt)

### write

    public void write(PrintWriter writer, Janitor janitor)

  Writes error messages to the specified PrintWriter.