Package org.springframework.web
Class ErrorResponseException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.springframework.core.NestedRuntimeException
org.springframework.web.ErrorResponseException
- All Implemented Interfaces:
- Serializable,- ErrorResponse
- Direct Known Subclasses:
- ResponseStatusException
RuntimeException that implements ErrorResponse to expose
 an HTTP status, response headers, and a body formatted as an RFC 7807
 ProblemDetail.
 The exception can be used as is, or it can be extended as a more specific
 exception that populates the type or
 detail fields, or potentially adds
 other non-standard properties.
- Since:
- 6.0
- Author:
- Rossen Stoyanchev
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.springframework.web.ErrorResponseErrorResponse.Builder
- 
Constructor SummaryConstructorsConstructorDescriptionErrorResponseException(HttpStatusCode status) Constructor with anHttpStatusCode.ErrorResponseException(HttpStatusCode status, Throwable cause) Constructor with anHttpStatusCodeand an optional cause.ErrorResponseException(HttpStatusCode status, ProblemDetail body, Throwable cause) Constructor with a givenProblemDetailinstance, possibly a subclass ofProblemDetailwith extended fields.ErrorResponseException(HttpStatusCode status, ProblemDetail body, Throwable cause, String messageDetailCode, Object[] messageDetailArguments) Constructor with a givenProblemDetail, and aMessageSourcecode and arguments to resolve the detail message with.
- 
Method SummaryModifier and TypeMethodDescriptionfinal ProblemDetailgetBody()Return the body for the response.Object[]Return arguments to use along with amessage codeto resolve the problem "detail" for this exception through aMessageSource.Return a code to use to resolve the problem "detail" for this exception through aMessageSource.Return headers to use for the response.Return the HTTP status code to use for the response.voidSet thedetailfield of the response body.voidsetInstance(URI instance) Set theinstancefield of the response body.voidSet thetitlefield of the response body.voidSet thetypefield of the response body.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, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.web.ErrorResponsegetDetailMessageArguments, getTitleMessageCode, getTypeMessageCode, updateAndGetBody
- 
Constructor Details- 
ErrorResponseExceptionConstructor with anHttpStatusCode.
- 
ErrorResponseExceptionConstructor with anHttpStatusCodeand an optional cause.
- 
ErrorResponseExceptionConstructor with a givenProblemDetailinstance, possibly a subclass ofProblemDetailwith extended fields.
- 
ErrorResponseExceptionpublic ErrorResponseException(HttpStatusCode status, ProblemDetail body, @Nullable Throwable cause, @Nullable String messageDetailCode, @Nullable Object[] messageDetailArguments) Constructor with a givenProblemDetail, and aMessageSourcecode and arguments to resolve the detail message with.- Since:
- 6.0
 
 
- 
- 
Method Details- 
getStatusCodeDescription copied from interface:ErrorResponseReturn the HTTP status code to use for the response.- Specified by:
- getStatusCodein interface- ErrorResponse
 
- 
getHeadersDescription copied from interface:ErrorResponseReturn headers to use for the response.- Specified by:
- getHeadersin interface- ErrorResponse
 
- 
setTypeSet thetypefield of the response body.- Parameters:
- type- the problem type
 
- 
setTitleSet thetitlefield of the response body.- Parameters:
- title- the problem title
 
- 
setDetailSet thedetailfield of the response body.- Parameters:
- detail- the problem detail
 
- 
setInstanceSet theinstancefield of the response body.- Parameters:
- instance- the problem instance
 
- 
getBodyReturn the body for the response. To customize the body content, use:By default, the status field of ProblemDetailis initialized from the status provided to the constructor, which in turn may also initialize the title field from the status reason phrase, if the status is well-known. The instance field, if not set, is initialized from the request path when aProblemDetailis returned from an@ExceptionHandlermethod.- Specified by:
- getBodyin interface- ErrorResponse
 
- 
getDetailMessageCodeDescription copied from interface:ErrorResponseReturn a code to use to resolve the problem "detail" for this exception through aMessageSource.By default this is initialized via ErrorResponse.getDefaultDetailMessageCode(Class, String).- Specified by:
- getDetailMessageCodein interface- ErrorResponse
 
- 
getDetailMessageArgumentsDescription copied from interface:ErrorResponseReturn arguments to use along with amessage codeto resolve the problem "detail" for this exception through aMessageSource. The arguments are expanded into placeholders of the message value, e.g. "Invalid content type {0}".- Specified by:
- getDetailMessageArgumentsin interface- ErrorResponse
 
- 
getMessage- Overrides:
- getMessagein class- Throwable
 
 
-