com.google.javascript.rhino
Class SimpleErrorReporter

java.lang.Object
  extended by com.google.javascript.rhino.SimpleErrorReporter
All Implemented Interfaces:
ErrorReporter

public class SimpleErrorReporter
extends Object
implements ErrorReporter

A simple ErrorReporter that collects warnings and errors and makes them accessible via errors() and warnings().


Constructor Summary
SimpleErrorReporter()
           
 
Method Summary
 void error(String message, String sourceName, int line, String lineSource, int lineOffset)
          Report an error.
 List<String> errors()
          Returns the list of errors, or null if there were none.
 EvaluatorException runtimeError(String message, String sourceName, int line, String lineSource, int lineOffset)
          Creates an EvaluatorException that may be thrown.
 void warning(String message, String sourceName, int line, String lineSource, int lineOffset)
          Report a warning.
 List<String> warnings()
          Returns the list of warnings, or null if there were none.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleErrorReporter

public SimpleErrorReporter()
Method Detail

warning

public void warning(String message,
                    String sourceName,
                    int line,
                    String lineSource,
                    int lineOffset)
Description copied from interface: ErrorReporter
Report a warning. The implementing class may choose to ignore the warning if it desires.

Specified by:
warning in interface ErrorReporter
Parameters:
message - a String describing the warning
sourceName - a String describing the JavaScript source where the warning occured; typically a filename or URL
line - the line number associated with the warning
lineSource - the text of the line (may be null)
lineOffset - the offset into lineSource where problem was detected

error

public void error(String message,
                  String sourceName,
                  int line,
                  String lineSource,
                  int lineOffset)
Description copied from interface: ErrorReporter
Report an error. The implementing class is free to throw an exception if it desires. If execution has not yet begun, the JavaScript engine is free to find additional errors rather than terminating the translation. It will not execute a script that had errors, however.

Specified by:
error in interface ErrorReporter
Parameters:
message - a String describing the error
sourceName - a String describing the JavaScript source where the error occured; typically a filename or URL
line - the line number associated with the error
lineSource - the text of the line (may be null)
lineOffset - the offset into lineSource where problem was detected

runtimeError

public EvaluatorException runtimeError(String message,
                                       String sourceName,
                                       int line,
                                       String lineSource,
                                       int lineOffset)
Description copied from interface: ErrorReporter
Creates an EvaluatorException that may be thrown. runtimeErrors, unlike errors, will always terminate the current script.

Specified by:
runtimeError in interface ErrorReporter
Parameters:
message - a String describing the error
sourceName - a String describing the JavaScript source where the error occured; typically a filename or URL
line - the line number associated with the error
lineSource - the text of the line (may be null)
lineOffset - the offset into lineSource where problem was detected
Returns:
an EvaluatorException that will be thrown.

errors

public List<String> errors()
Returns the list of errors, or null if there were none.


warnings

public List<String> warnings()
Returns the list of warnings, or null if there were none.