001/*
002 * Copyright 2002-2017 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 unknown (or custom) HTTP status code is received.
026 *
027 * @author Rossen Stoyanchev
028 * @since 3.2
029 */
030public class UnknownHttpStatusCodeException extends RestClientResponseException {
031
032        private static final long serialVersionUID = 7103980251635005491L;
033
034
035        /**
036         * Construct a new instance of {@code HttpStatusCodeException} based on an
037         * {@link HttpStatus}, status text, and response body content.
038         * @param rawStatusCode the raw status code value
039         * @param statusText the status text
040         * @param responseHeaders the response headers (may be {@code null})
041         * @param responseBody the response body content (may be {@code null})
042         * @param responseCharset the response body charset (may be {@code null})
043         */
044        public UnknownHttpStatusCodeException(int rawStatusCode, String statusText,
045                        HttpHeaders responseHeaders, byte[] responseBody, Charset responseCharset) {
046
047                super("Unknown status code [" + rawStatusCode + "]" + " " + statusText,
048                                rawStatusCode, statusText, responseHeaders, responseBody, responseCharset);
049        }
050
051}