View Javadoc

1   /**
2    * Copyright (c) 2002-2015, JWebUnit team.
3    *
4    * This file is part of JWebUnit.
5    *
6    * JWebUnit is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Lesser General Public License as published by
8    * the Free Software Foundation, either version 3 of the License, or
9    * (at your option) any later version.
10   *
11   * JWebUnit is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.
15   *
16   * You should have received a copy of the GNU Lesser General Public License
17   * along with JWebUnit.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package net.sourceforge.jwebunit.exception;
20  
21  /**
22   * This name reflects the name all of exceptions that will be thrown from a specific "testing engine".
23   * 
24   * All testing engines will respond, if necessary, using this exception instead of the testing specific engine
25   * exceptions.
26   * 
27   * 
28   * @author Nicholas Neuberger
29   */
30  public class TestingEngineResponseException extends RuntimeException {
31  
32  	private static final long serialVersionUID = 1L;
33      private int httpStatusCode = -1;
34  
35      /**
36       * 
37       */
38      public TestingEngineResponseException() {
39          super();
40      }
41  
42      public TestingEngineResponseException(int httpStatusCode) {
43          super();
44          this.httpStatusCode = httpStatusCode;
45      }
46  
47      public TestingEngineResponseException(int httpStatusCode, String msg) {
48          super(msg);
49          this.httpStatusCode = httpStatusCode;
50      }
51  
52      public TestingEngineResponseException(int httpStatusCode, String msg, Throwable ex) {
53          super(msg, ex);
54          this.httpStatusCode = httpStatusCode;
55      }
56  
57      public TestingEngineResponseException(int httpStatusCode, Exception e) {
58          super("The server return "+httpStatusCode+" HTTP code.", e);
59          this.httpStatusCode = httpStatusCode;
60      }
61  
62      /**
63       * @param arg0
64       */
65      public TestingEngineResponseException(String msg) {
66          super(msg);
67      }
68  
69      /**
70       * @param arg0
71       * @param arg1
72       */
73      public TestingEngineResponseException(String msg, Throwable ex) {
74          super(msg, ex);
75      }
76  
77      /**
78       * @param arg0
79       */
80      public TestingEngineResponseException(Throwable ex) {
81          super(ex);
82      }
83  
84      /**
85       * Return the HTTP status code that throw this Exception or -1 if this exception
86       * was not thrown because of HTTP status code.
87       * @return
88       */
89      public int getHttpStatusCode() {
90          return httpStatusCode;
91      }
92  
93  }