01: /* Licensed to the Apache Software Foundation (ASF) under one or more
02: * contributor license agreements. See the NOTICE file distributed with
03: * this work for additional information regarding copyright ownership.
04: * The ASF licenses this file to You under the Apache License, Version 2.0
05: * (the "License"); you may not use this file except in compliance with
06: * the License. You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 java.net;
18:
19: import java.io.IOException;
20:
21: /**
22: * The exception to be thrown when a request cannot be retried.
23: */
24: public class HttpRetryException extends IOException {
25:
26: private static final long serialVersionUID = -9186022286469111381L;
27:
28: private int responseCode;
29:
30: private String location = null;
31:
32: /**
33: * new a HttpRetryException by given detail message and responseCode
34: *
35: * @param detail
36: * detail for this exception
37: * @param code
38: * http response code to return
39: */
40: public HttpRetryException(String detail, int code) {
41: super (detail);
42: responseCode = code;
43: }
44:
45: /**
46: * new a HttpRetryException by given detail message, responseCode and the
47: * Location response header
48: *
49: * @param detail
50: * detail for this exception
51: * @param code
52: * http response code to return
53: * @param location
54: * the error resulted from redirection, the Location header can
55: * be recorded
56: */
57: public HttpRetryException(String detail, int code, String location) {
58: super (detail);
59: responseCode = code;
60: this .location = location;
61: }
62:
63: /**
64: * @return the Location header recorded
65: */
66: public String getLocation() {
67: return location;
68: }
69:
70: /**
71: * @return the detail reason for this exception
72: */
73: public String getReason() {
74: return getMessage();
75: }
76:
77: /**
78: * @return a http response code
79: */
80: public int responseCode() {
81: return responseCode;
82: }
83: }
|