1 /*
2 * Copyright 2008-2011 Thomas Nichols. http://blog.thomnichols.org
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 * You are receiving this code free of charge, which represents many hours of
17 * effort from other individuals and corporations. As a responsible member
18 * of the community, you are encouraged (but not required) to donate any
19 * enhancements or improvements back to the community under a similar open
20 * source license. Thank you. -TMN
21 */
22 package groovyx.net.http;
23
24 /**
25 * Thrown when a response body is parsed unsuccessfully. This most often
26 * occurs when a server returns an error status code and sends a different
27 * content-type body from what was expected. You can inspect the response
28 * content-type by calling <code>ex.response.contentType</code>.
29 *
30 * @author <a href='mailto:tomstrummer+httpbuilder@gmail.com'>Tom Nichols</a>
31 * @since 0.5.0
32 */
33 public class ResponseParseException extends HttpResponseException {
34
35 private static final long serialVersionUID = -1398234959324603287L;
36
37 /* TODO this is a bit wonky because org.apache.http...HttpResponseException
38 does not have a constructor to pass the 'cause'. But I want this to
39 extend HttpResponseException so that one exception type can catch
40 everything thrown from HttpBuilder. */
41 private Throwable cause;
42
43 public ResponseParseException( HttpResponseDecorator response, Throwable cause ) {
44 super( response );
45 this.cause = cause;
46 }
47
48 @Override public Throwable getCause() { return this.cause; }
49 }