| 1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
| 2 | * |
| 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
| 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 | |
| 7 | // API class |
| 8 | |
| 9 | package org.mozilla.javascript; |
| 10 | |
| 11 | /** |
| 12 | * This is interface defines a protocol for the reporting of |
| 13 | * errors during JavaScript translation or execution. |
| 14 | * |
| 15 | * @author Norris Boyd |
| 16 | */ |
| 17 | |
| 18 | public interface ErrorReporter { |
| 19 | |
| 20 | /** |
| 21 | * Report a warning. |
| 22 | * |
| 23 | * The implementing class may choose to ignore the warning |
| 24 | * if it desires. |
| 25 | * |
| 26 | * @param message a String describing the warning |
| 27 | * @param sourceName a String describing the JavaScript source |
| 28 | * where the warning occured; typically a filename or URL |
| 29 | * @param line the line number associated with the warning |
| 30 | * @param lineSource the text of the line (may be null) |
| 31 | * @param lineOffset the offset into lineSource where problem was detected |
| 32 | */ |
| 33 | void warning(String message, String sourceName, int line, |
| 34 | String lineSource, int lineOffset); |
| 35 | |
| 36 | /** |
| 37 | * Report an error. |
| 38 | * |
| 39 | * The implementing class is free to throw an exception if |
| 40 | * it desires. |
| 41 | * |
| 42 | * If execution has not yet begun, the JavaScript engine is |
| 43 | * free to find additional errors rather than terminating |
| 44 | * the translation. It will not execute a script that had |
| 45 | * errors, however. |
| 46 | * |
| 47 | * @param message a String describing the error |
| 48 | * @param sourceName a String describing the JavaScript source |
| 49 | * where the error occured; typically a filename or URL |
| 50 | * @param line the line number associated with the error |
| 51 | * @param lineSource the text of the line (may be null) |
| 52 | * @param lineOffset the offset into lineSource where problem was detected |
| 53 | */ |
| 54 | void error(String message, String sourceName, int line, |
| 55 | String lineSource, int lineOffset); |
| 56 | |
| 57 | /** |
| 58 | * Creates an EvaluatorException that may be thrown. |
| 59 | * |
| 60 | * runtimeErrors, unlike errors, will always terminate the |
| 61 | * current script. |
| 62 | * |
| 63 | * @param message a String describing the error |
| 64 | * @param sourceName a String describing the JavaScript source |
| 65 | * where the error occured; typically a filename or URL |
| 66 | * @param line the line number associated with the error |
| 67 | * @param lineSource the text of the line (may be null) |
| 68 | * @param lineOffset the offset into lineSource where problem was detected |
| 69 | * @return an EvaluatorException that will be thrown. |
| 70 | */ |
| 71 | EvaluatorException runtimeError(String message, String sourceName, |
| 72 | int line, String lineSource, |
| 73 | int lineOffset); |
| 74 | } |