View Javadoc
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  /**
18   * An error that is thrown when a script has been running too long.
19   *
20   * @author Andre Soereng
21   * @author Ronald Brill
22   */
23  public class TimeoutError extends Error {
24      private final long allowedTime_;
25      private final long executionTime_;
26  
27      TimeoutError(final long allowedTime, final long executionTime) {
28          super("Javascript execution takes too long (allowed: " + allowedTime
29                  + ", already elapsed: " + executionTime + ")");
30          allowedTime_ = allowedTime;
31          executionTime_ = executionTime;
32      }
33  
34      /**
35       * Returns the allowed time.
36       * @return the allowed time
37       */
38      long getAllowedTime() {
39          return allowedTime_;
40      }
41  
42      /**
43       * Returns the execution time.
44       * @return the execution time
45       */
46      long getExecutionTime() {
47          return executionTime_;
48      }
49  }