Package org.springframework.web.server
Class ResponseStatusException
- java.lang.Object
- java.lang.Throwable
- java.lang.Exception
- java.lang.RuntimeException
- org.springframework.core.NestedRuntimeException
- org.springframework.web.server.ResponseStatusException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
MediaTypeNotSupportedStatusException
,MethodNotAllowedException
,NotAcceptableStatusException
,ServerErrorException
,ServerWebInputException
,UnsupportedMediaTypeStatusException
public class ResponseStatusException extends NestedRuntimeException
Base class for exceptions associated with specific HTTP response status codes.- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Juergen Hoeller
- See Also:
- Serialized Form
Constructor Summary
Constructors Constructor Description ResponseStatusException(HttpStatus status)
Constructor with a response status.ResponseStatusException(HttpStatus status, String reason)
Constructor with a response status and a reason to add to the exception message as explanation.ResponseStatusException(HttpStatus status, String reason, Throwable cause)
Constructor with a response status and a reason to add to the exception message as explanation, as well as a nested exception.
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Map<String,String>
getHeaders()
Deprecated.as of 5.1.13 in favor ofgetResponseHeaders()
String
getMessage()
Return the detail message, including the message from the nested exception if there is one.String
getReason()
The reason explaining the exception (potentiallynull
or empty).HttpHeaders
getResponseHeaders()
Return headers associated with the exception that should be added to the error response, e.g.HttpStatus
getStatus()
Return the HTTP status associated with this exception.Methods inherited from class org.springframework.core.NestedRuntimeException
contains, getMostSpecificCause, getRootCause
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
Constructor Detail
ResponseStatusException
public ResponseStatusException(HttpStatus status)
Constructor with a response status.- Parameters:
status
- the HTTP status (required)
ResponseStatusException
public ResponseStatusException(HttpStatus status, @Nullable String reason)
Constructor with a response status and a reason to add to the exception message as explanation.- Parameters:
status
- the HTTP status (required)reason
- the associated reason (optional)
ResponseStatusException
public ResponseStatusException(HttpStatus status, @Nullable String reason, @Nullable Throwable cause)
Constructor with a response status and a reason to add to the exception message as explanation, as well as a nested exception.- Parameters:
status
- the HTTP status (required)reason
- the associated reason (optional)cause
- a nested exception (optional)
Method Detail
getStatus
public HttpStatus getStatus()
Return the HTTP status associated with this exception.
getHeaders
@Deprecated public Map<String,String> getHeaders()
Deprecated.as of 5.1.13 in favor ofgetResponseHeaders()
Return headers associated with the exception that should be added to the error response, e.g. "Allow", "Accept", etc.The default implementation in this class returns an empty map.
- Since:
- 5.1.11
getResponseHeaders
public HttpHeaders getResponseHeaders()
Return headers associated with the exception that should be added to the error response, e.g. "Allow", "Accept", etc.The default implementation in this class returns empty headers.
- Since:
- 5.1.13
getReason
@Nullable public String getReason()
The reason explaining the exception (potentiallynull
or empty).
getMessage
public String getMessage()
Description copied from class:NestedRuntimeException
Return the detail message, including the message from the nested exception if there is one.- Overrides:
getMessage
in classNestedRuntimeException