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:
- MethodNotAllowedException,- NotAcceptableStatusException,- ServerErrorException,- ServerWebInputException,- UnsupportedMediaTypeStatusException
Base class for exceptions associated with specific HTTP response status codes.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Juergen Hoeller
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionResponseStatusException(int rawStatusCode, 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.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 SummaryModifier and TypeMethodDescriptionReturn the detail message, including the message from the nested exception if there is one.intReturn the HTTP status code (potentially non-standard and not resolvable through theHttpStatusenum) as an integer.The reason explaining the exception (potentiallynullor empty).Return headers associated with the exception that should be added to the error response, e.g.Return the HTTP status associated with this exception.Methods inherited from class org.springframework.core.NestedRuntimeExceptioncontains, getMostSpecificCause, getRootCauseMethods inherited from class java.lang.ThrowableaddSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
- 
Constructor Details- 
ResponseStatusExceptionConstructor with a response status.- Parameters:
- status- the HTTP status (required)
 
- 
ResponseStatusExceptionConstructor 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)
 
- 
ResponseStatusExceptionpublic 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)
 
- 
ResponseStatusExceptionpublic ResponseStatusException(int rawStatusCode, @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:
- rawStatusCode- the HTTP status code value
- reason- the associated reason (optional)
- cause- a nested exception (optional)
- Since:
- 5.3
 
 
- 
- 
Method Details- 
getStatusReturn the HTTP status associated with this exception.- Throws:
- IllegalArgumentException- in case of an unknown HTTP status code
- Since:
- #getRawStatusCode()
- See Also:
 
- 
getRawStatusCodepublic int getRawStatusCode()Return the HTTP status code (potentially non-standard and not resolvable through theHttpStatusenum) as an integer.- Returns:
- the HTTP status as an integer value
- Since:
- 5.3
- See Also:
 
- 
getResponseHeadersReturn 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
 
- 
getReasonThe reason explaining the exception (potentiallynullor empty).
- 
getMessageDescription copied from class:NestedRuntimeExceptionReturn the detail message, including the message from the nested exception if there is one.- Overrides:
- getMessagein class- NestedRuntimeException
 
 
-