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 5xx is received. 026 * 027 * @author Arjen Poutsma 028 * @since 3.0 029 * @see DefaultResponseErrorHandler 030 */ 031public class HttpServerErrorException extends HttpStatusCodeException { 032 033 private static final long serialVersionUID = -2915754006618138282L; 034 035 036 /** 037 * Construct a new instance of {@code HttpServerErrorException} based on 038 * an {@link HttpStatus}. 039 * @param statusCode the status code 040 */ 041 public HttpServerErrorException(HttpStatus statusCode) { 042 super(statusCode); 043 } 044 045 /** 046 * Construct a new instance of {@code HttpServerErrorException} based on 047 * an {@link HttpStatus} and status text. 048 * @param statusCode the status code 049 * @param statusText the status text 050 */ 051 public HttpServerErrorException(HttpStatus statusCode, String statusText) { 052 super(statusCode, statusText); 053 } 054 055 /** 056 * Construct a new instance of {@code HttpServerErrorException} 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 * @since 3.0.5 063 */ 064 public HttpServerErrorException(HttpStatus statusCode, String statusText, 065 byte[] responseBody, Charset responseCharset) { 066 067 super(statusCode, statusText, responseBody, responseCharset); 068 } 069 070 /** 071 * Construct a new instance of {@code HttpServerErrorException} based on 072 * an {@link HttpStatus}, status text, and response body content. 073 * @param statusCode the status code 074 * @param statusText the status text 075 * @param responseHeaders the response headers (may be {@code null}) 076 * @param responseBody the response body content (may be {@code null}) 077 * @param responseCharset the response body charset (may be {@code null}) 078 * @since 3.1.2 079 */ 080 public HttpServerErrorException(HttpStatus statusCode, String statusText, 081 HttpHeaders responseHeaders, byte[] responseBody, Charset responseCharset) { 082 083 super(statusCode, statusText, responseHeaders, responseBody, responseCharset); 084 } 085 086}