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 7808
 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 fields.
- Since:
- 6.0
- Author:
- Rossen Stoyanchev
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionErrorResponseException(int status, Throwable cause) Constructor that accepts any status value, possibly not resolvable as anHttpStatusenum, and an optional cause.ErrorResponseException(int status, ProblemDetail body, Throwable cause) Constructor with a givenProblemDetailinstance, possibly a subclass ofProblemDetailwith extended fields.ErrorResponseException(HttpStatus status) Constructor with a well-knownHttpStatus.ErrorResponseException(HttpStatus status, Throwable cause) Constructor with a well-knownHttpStatusand an optional cause.
- 
Method SummaryModifier and TypeMethodDescriptionfinal ProblemDetailgetBody()Return the body for the response.Return headers to use for the response.Return the detail message, including the message from the nested exception if there is one.intReturn the HTTP status value for the response, potentially non-standard and not resolvable viaHttpStatus.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.ErrorResponsegetStatus
- 
Constructor Details- 
ErrorResponseExceptionConstructor with a well-knownHttpStatus.
- 
ErrorResponseExceptionConstructor with a well-knownHttpStatusand an optional cause.
- 
ErrorResponseExceptionConstructor that accepts any status value, possibly not resolvable as anHttpStatusenum, and an optional cause.
- 
ErrorResponseExceptionConstructor with a givenProblemDetailinstance, possibly a subclass ofProblemDetailwith extended fields.
 
- 
- 
Method Details- 
getRawStatusCodepublic int getRawStatusCode()Description copied from interface:ErrorResponseReturn the HTTP status value for the response, potentially non-standard and not resolvable viaHttpStatus.- Specified by:
- getRawStatusCodein 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
 
- 
getMessageDescription copied from class:NestedRuntimeExceptionReturn the detail message, including the message from the nested exception if there is one.- Overrides:
- getMessagein class- NestedRuntimeException
 
 
-