Package org.springframework.web.client

# Class HttpStatusCodeException

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

All Implemented Interfaces:
  `Serializable`

Direct Known Subclasses:
  `HttpClientErrorException`, `HttpServerErrorException`

public abstract class HttpStatusCodeException extends RestClientResponseException
Abstract base class for exceptions based on an `HttpStatusCode`.

Since:
  3.0
Author:
  Arjen Poutsma, Chris Beams, Rossen Stoyanchev
See Also:
  - Serialized Form

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`HttpStatusCodeException(String message, HttpStatusCode statusCode, String statusText, HttpHeaders responseHeaders, byte[] responseBody, Charset responseCharset)`
Construct instance with an `HttpStatusCode`, status text, content, and a response charset.
`protected`
`HttpStatusCodeException(HttpStatusCode statusCode)`
Construct a new instance with an `HttpStatusCode`.
`protected`
`HttpStatusCodeException(HttpStatusCode statusCode, String statusText)`
Construct a new instance with an `HttpStatusCode` and status text.
`protected`
`HttpStatusCodeException(HttpStatusCode statusCode, String statusText, byte[] responseBody, Charset responseCharset)`
Construct instance with an `HttpStatusCode`, status text, and content.
`protected`
`HttpStatusCodeException(HttpStatusCode statusCode, String statusText, HttpHeaders responseHeaders, byte[] responseBody, Charset responseCharset)`
Construct instance with an `HttpStatusCode`, status text, content, and a response charset.

## Method Summary

### 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

### HttpStatusCodeException

protected HttpStatusCodeException(HttpStatusCode statusCode)
Construct a new instance with an `HttpStatusCode`.

Parameters:
  `statusCode` - the status code

### HttpStatusCodeException

protected HttpStatusCodeException(HttpStatusCode statusCode, String statusText)
Construct a new instance with an `HttpStatusCode` and status text.

Parameters:
  `statusCode` - the status code
  `statusText` - the status text

### HttpStatusCodeException

protected HttpStatusCodeException(HttpStatusCode statusCode, String statusText, @Nullable byte[] responseBody, @Nullable Charset responseCharset)
Construct instance with an `HttpStatusCode`, status text, and content.

Parameters:
  `statusCode` - the status code
  `statusText` - the status text
  `responseBody` - the response body content, may be `null`
  `responseCharset` - the response body charset, may be `null`
Since:
  3.0.5

### HttpStatusCodeException

protected HttpStatusCodeException(HttpStatusCode statusCode, String statusText, @Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody, @Nullable Charset responseCharset)
Construct instance with an `HttpStatusCode`, status text, content, and a response charset.

Parameters:
  `statusCode` - the status code
  `statusText` - the status text
  `responseHeaders` - the response headers, may be `null`
  `responseBody` - the response body content, may be `null`
  `responseCharset` - the response body charset, may be `null`
Since:
  3.1.2

### HttpStatusCodeException

protected HttpStatusCodeException(String message, HttpStatusCode statusCode, String statusText, @Nullable HttpHeaders responseHeaders, @Nullable byte[] responseBody, @Nullable Charset responseCharset)
Construct instance with an `HttpStatusCode`, status text, content, and a response charset.

Parameters:
  `message` - the exception message
  `statusCode` - the status code
  `statusText` - the status text
  `responseHeaders` - the response headers, may be `null`
  `responseBody` - the response body content, may be `null`
  `responseCharset` - the response body charset, may be `null`
Since:
  5.2.2