1 /* 2 * Copyright 2007-2012 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 private static final long serialVersionUID = 3144858033479971939L; 29 30 protected int statusCode = -1; 31 32 /** 33 * Constructor. 34 * 35 * @param msg Error message. 36 */ 37 public HttpAccessException(String msg) { 38 super(msg); 39 } 40 41 /** 42 * Constructor. 43 * 44 * @param msg Error message. 45 * @param statusCode HTTP status code. 46 */ 47 public HttpAccessException(String msg, int statusCode) { 48 this(msg); 49 this.statusCode = statusCode; 50 } 51 52 /** 53 * Constructor. 54 * 55 * @param msg Error message. 56 * @param cause Cause of error. 57 */ 58 public HttpAccessException(String msg, Throwable cause) { 59 super(msg, cause); 60 } 61 62 /** 63 * Constructor. 64 * 65 * @param msg Error message. 66 * @param cause Cause of error. 67 * @param statusCode HTTP status code. 68 */ 69 public HttpAccessException(String msg, Throwable cause, int statusCode) { 70 this(msg, cause); 71 this.statusCode = statusCode; 72 } 73 74 }