Package org.springframework.web.client

# Class HttpServerErrorException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.springframework.core.NestedRuntimeException
org.springframework.web.client.RestClientException
org.springframework.web.client.RestClientResponseException
org.springframework.web.client.HttpStatusCodeException
org.springframework.web.client.HttpServerErrorException

All Implemented Interfaces:
  `Serializable`

Direct Known Subclasses:
  `HttpServerErrorException.BadGateway`, `HttpServerErrorException.GatewayTimeout`, `HttpServerErrorException.InternalServerError`, `HttpServerErrorException.NotImplemented`, `HttpServerErrorException.ServiceUnavailable`

public class HttpServerErrorException extends HttpStatusCodeException
Exception thrown when an HTTP 5xx is received.

Since:
  3.0
Author:
  Arjen Poutsma
See Also:
  - `DefaultResponseErrorHandler`
  - Serialized Form

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static final class`
`HttpServerErrorException.BadGateway`
`HttpServerErrorException` for HTTP status 502 Bad Gateway.
`static final class`
`HttpServerErrorException.GatewayTimeout`
`HttpServerErrorException` for status HTTP 504 Gateway Timeout.
`static final class`
`HttpServerErrorException.InternalServerError`
`HttpServerErrorException` for status HTTP 500 Internal Server Error.
`static final class`
`HttpServerErrorException.NotImplemented`
`HttpServerErrorException` for status HTTP 501 Not Implemented.
`static final class`
`HttpServerErrorException.ServiceUnavailable`
`HttpServerErrorException` for status HTTP 503 Service Unavailable.

## Constructor Summary

Constructors
Constructor
Description
`HttpServerErrorException(String message, HttpStatusCode statusCode, String statusText, HttpHeaders headers, byte[] body, Charset charset)`
Constructor with a status code and status text, headers, content, and a prepared message.
`HttpServerErrorException(HttpStatusCode statusCode)`
Constructor with a status code only.
`HttpServerErrorException(HttpStatusCode statusCode, String statusText)`
Constructor with a status code and status text.
`HttpServerErrorException(HttpStatusCode statusCode, String statusText, byte[] body, Charset charset)`
Constructor with a status code and status text, and content.
`HttpServerErrorException(HttpStatusCode statusCode, String statusText, HttpHeaders headers, byte[] body, Charset charset)`
Constructor with a status code and status text, headers, and content.

## Method Summary

Modifier and Type
Method
Description
`static HttpServerErrorException`
`create(String message, HttpStatusCode statusCode, String statusText, HttpHeaders headers, byte[] body, Charset charset)`
Variant of `create(String, HttpStatusCode, String, HttpHeaders, byte[], Charset)` with an optional prepared message.
`static HttpServerErrorException`
`create(HttpStatusCode statusCode, String statusText, HttpHeaders headers, byte[] body, Charset charset)`
Create an `HttpServerErrorException` or an HTTP status specific subclass.

### Methods inherited from class org.springframework.web.client.RestClientResponseException

`getRawStatusCode, getResponseBodyAs, getResponseBodyAs, getResponseBodyAsByteArray, getResponseBodyAsString, getResponseBodyAsString, getResponseHeaders, getStatusCode, getStatusText, setBodyConvertFunction`

### Methods inherited from class org.springframework.core.NestedRuntimeException

`contains, getMostSpecificCause, getRootCause`

### Methods inherited from class java.lang.Throwable

`addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### HttpServerErrorException

public HttpServerErrorException(HttpStatusCode statusCode)
Constructor with a status code only.

### HttpServerErrorException

public HttpServerErrorException(HttpStatusCode statusCode, String statusText)
Constructor with a status code and status text.

### HttpServerErrorException

public HttpServerErrorException(HttpStatusCode statusCode, String statusText, @Nullable byte[] body, @Nullable Charset charset)
Constructor with a status code and status text, and content.

### HttpServerErrorException

public HttpServerErrorException(HttpStatusCode statusCode, String statusText, @Nullable HttpHeaders headers, @Nullable byte[] body, @Nullable Charset charset)
Constructor with a status code and status text, headers, and content.

### HttpServerErrorException

public HttpServerErrorException(String message, HttpStatusCode statusCode, String statusText, @Nullable HttpHeaders headers, @Nullable byte[] body, @Nullable Charset charset)
Constructor with a status code and status text, headers, content, and a prepared message.

Since:
  5.2.2

## Method Details

### create

public static HttpServerErrorException create(HttpStatusCode statusCode, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset)
Create an `HttpServerErrorException` or an HTTP status specific subclass.

Since:
  5.1

### create

public static HttpServerErrorException create(@Nullable String message, HttpStatusCode statusCode, String statusText, HttpHeaders headers, byte[] body, @Nullable Charset charset)
Variant of `create(String, HttpStatusCode, String, HttpHeaders, byte[], Charset)` with an optional prepared message.

Since:
  5.2.2.