001/*
002 * Copyright 2008-2011 Thomas Nichols.  http://blog.thomnichols.org
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * You are receiving this code free of charge, which represents many hours of
017 * effort from other individuals and corporations.  As a responsible member
018 * of the community, you are encouraged (but not required) to donate any
019 * enhancements or improvements back to the community under a similar open
020 * source license.  Thank you. -TMN
021 */
022package groovyx.net.http;
023
024/**
025 * Thrown when a response body is parsed unsuccessfully.  This most often
026 * occurs when a server returns an error status code and sends a different
027 * content-type body from what was expected.  You can inspect the response
028 * content-type by calling <code>ex.response.contentType</code>.
029 *
030 * @author <a href='mailto:tomstrummer+httpbuilder@gmail.com'>Tom Nichols</a>
031 * @since 0.5.0
032 */
033public class ResponseParseException extends HttpResponseException {
034
035    private static final long serialVersionUID = -1398234959324603287L;
036
037    /* TODO this is a bit wonky because org.apache.http...HttpResponseException
038       does not have a constructor to pass the 'cause'.  But I want this to
039       extend HttpResponseException so that one exception type can catch
040       everything thrown from HttpBuilder. */
041    private Throwable cause;
042
043    public ResponseParseException( HttpResponseDecorator response, Throwable cause ) {
044        super( response );
045        this.cause = cause;
046    }
047
048    @Override public Throwable getCause() { return this.cause; }
049}