View Javadoc

1   /*
2    * Copyright 2002-2006 the original author or authors.
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    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springbyexample.httpclient;
18  
19  import org.springframework.core.NestedRuntimeException;
20  
21  /**
22   * HTTP runtime exception for any HTTP error.
23   * 
24   * @author David Winterfeldt
25   */
26  public class HttpAccessException extends NestedRuntimeException {
27  
28      protected int statusCode = -1;
29      
30      /**
31       * Constructor.
32       * 
33       * @param   msg         Error message.
34       */
35      public HttpAccessException(String msg) {
36          super(msg);
37      }
38  
39      /**
40       * Constructor.
41       * 
42       * @param   msg         Error message.
43       * @param   statusCode  HTTP status code.    
44       */
45      public HttpAccessException(String msg, int statusCode) {
46          this(msg);
47          this.statusCode = statusCode;
48      }
49  
50      /**
51       * Constructor.
52       * 
53       * @param   msg         Error message.
54       * @param   cause       Cause of error.
55       */
56      public HttpAccessException(String msg, Throwable cause) {
57          super(msg, cause);
58      }
59  
60      /**
61       * Constructor.
62       * 
63       * @param   msg         Error message.
64       * @param   cause       Cause of error.
65       * @param   statusCode  HTTP status code.    
66       */
67      public HttpAccessException(String msg, Throwable cause, int statusCode) {
68          this(msg, cause);
69          this.statusCode = statusCode;
70      }
71      
72  }