001/*
002 * Copyright 2002-2016 the original author or authors.
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 *      https://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
017package org.springframework.web.client;
018
019import java.nio.charset.Charset;
020
021import org.springframework.http.HttpHeaders;
022import org.springframework.http.HttpStatus;
023
024/**
025 * Exception thrown when an HTTP 4xx is received.
026 *
027 * @author Arjen Poutsma
028 * @since 3.0
029 * @see DefaultResponseErrorHandler
030 */
031public class HttpClientErrorException extends HttpStatusCodeException {
032
033        private static final long serialVersionUID = 5177019431887513952L;
034
035
036        /**
037         * Construct a new instance of {@code HttpClientErrorException} based on
038         * an {@link HttpStatus}.
039         * @param statusCode the status code
040         */
041        public HttpClientErrorException(HttpStatus statusCode) {
042                super(statusCode);
043        }
044
045        /**
046         * Construct a new instance of {@code HttpClientErrorException} based on
047         * an {@link HttpStatus} and status text.
048         * @param statusCode the status code
049         * @param statusText the status text
050         */
051        public HttpClientErrorException(HttpStatus statusCode, String statusText) {
052                super(statusCode, statusText);
053        }
054
055        /**
056         * Construct a new instance of {@code HttpClientErrorException} based on
057         * an {@link HttpStatus}, status text, and response body content.
058         * @param statusCode the status code
059         * @param statusText the status text
060         * @param responseBody the response body content (may be {@code null})
061         * @param responseCharset the response body charset (may be {@code null})
062         */
063        public HttpClientErrorException(HttpStatus statusCode, String statusText,
064                        byte[] responseBody, Charset responseCharset) {
065
066                super(statusCode, statusText, responseBody, responseCharset);
067        }
068
069        /**
070         * Construct a new instance of {@code HttpClientErrorException} based on
071         * an {@link HttpStatus}, status text, and response body content.
072         * @param statusCode the status code
073         * @param statusText the status text
074         * @param responseHeaders the response headers (may be {@code null})
075         * @param responseBody the response body content (may be {@code null})
076         * @param responseCharset the response body charset (may be {@code null})
077         * @since 3.1.2
078         */
079        public HttpClientErrorException(HttpStatus statusCode, String statusText,
080                        HttpHeaders responseHeaders, byte[] responseBody, Charset responseCharset) {
081
082                super(statusCode, statusText, responseHeaders, responseBody, responseCharset);
083        }
084
085}