1 /*
2 * Copyright (c) 2002-2025 Gargoyle Software Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * https://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 package org.htmlunit.javascript;
16
17 import java.net.MalformedURLException;
18 import java.net.URL;
19
20 import org.htmlunit.ScriptException;
21 import org.htmlunit.html.HtmlPage;
22
23 /**
24 * A listener for JavaScript exceptions.
25 *
26 * @author Ronald Brill
27 */
28 public interface JavaScriptErrorListener {
29
30 /**
31 * Informs about a javascript exceptions.
32 *
33 * @param page the page that causes the problem
34 * @param scriptException the occurred script exception
35 */
36 void scriptException(HtmlPage page, ScriptException scriptException);
37
38 /**
39 * Informs about a javascript timeout error.
40 *
41 * @param page the page that causes the problem
42 * @param allowedTime the max time allowed for the execution
43 * @param executionTime the already consumed time
44 */
45 void timeoutError(HtmlPage page, long allowedTime, long executionTime);
46
47 /**
48 * Informs about a malformed url referencing to script.
49 *
50 * @param page the page that causes the problem
51 * @param url the malformed url
52 * @param malformedURLException the occurred exception
53 */
54 void malformedScriptURL(HtmlPage page, String url, MalformedURLException malformedURLException);
55
56 /**
57 * Informs about an exception during load of a javascript file refereed from a page.
58 *
59 * @param page the page that causes the problem
60 * @param scriptUrl the url to load the script from
61 * @param exception the occurred exception
62 */
63 void loadScriptError(HtmlPage page, URL scriptUrl, Exception exception);
64
65 /**
66 * Informs about a javascript warning.
67 *
68 * @param message the message to be displayed
69 * @param sourceName the name of the source file
70 * @param line the line number
71 * @param lineSource the source code that failed
72 * @param lineOffset the line offset
73 */
74 void warn(String message, String sourceName, int line, String lineSource, int lineOffset);
75 }