Package org.springframework.web
Interface ErrorResponse.Builder
- Enclosing interface:
- ErrorResponse
public static interface ErrorResponse.Builder
Builder for an 
ErrorResponse.- 
Method SummaryModifier and TypeMethodDescriptionbuild()Build theErrorResponseinstance.default ErrorResponsebuild(MessageSource messageSource, Locale locale) Build theErrorResponseinstance and also resolve the "detail" and "title" through the givenMessageSource.Set the underlyingdetail.detailMessageArguments(Object... messageArguments) Set the arguments to provide to theMessageSourcelookup fordetailMessageCode(String).detailMessageCode(String messageCode) Customize theMessageSourcecode for looking up the value for the underlyingdetail.Add the given header value(s) under the given name.headers(Consumer<HttpHeaders> headersConsumer) Manipulate this response's headers with the given consumer.Set the underlyinginstancefield.Set a "dynamic"propertyon the underlyingProblemDetail.Set the underlyingtitlefield.titleMessageCode(String messageCode) Customize theMessageSourcecode for looking up the value for the underlyingtitle.Set the underlyingtypefield.
- 
Method Details- 
headerAdd the given header value(s) under the given name.- Parameters:
- headerName- the header name
- headerValues- the header value(s)
- Returns:
- the same builder instance
- See Also:
 
- 
headersManipulate this response's headers with the given consumer. This is useful to overwrite or remove existing values, or use any otherHttpHeadersmethods.- Parameters:
- headersConsumer- a function that consumes the- HttpHeaders
- Returns:
- the same builder instance
 
- 
detailSet the underlyingdetail.- Returns:
- the same builder instance
 
- 
detailMessageCodeCustomize theMessageSourcecode for looking up the value for the underlyingdetail.By default, this is set to ErrorResponse.getDefaultDetailMessageCode(Class, String)with the associated Exception type.- Parameters:
- messageCode- the message code to use
- Returns:
- the same builder instance
- See Also:
 
- 
detailMessageArgumentsSet the arguments to provide to theMessageSourcelookup fordetailMessageCode(String).- Parameters:
- messageArguments- the arguments to provide
- Returns:
- the same builder instance
- See Also:
 
- 
typeSet the underlyingtypefield.- Returns:
- the same builder instance
 
- 
titleSet the underlyingtitlefield.- Returns:
- the same builder instance
 
- 
titleMessageCodeCustomize theMessageSourcecode for looking up the value for the underlyingtitle.By default, set via ErrorResponse.getDefaultTitleMessageCode(Class)with the associated Exception type.- Parameters:
- messageCode- the message code to use
- Returns:
- the same builder instance
- See Also:
 
- 
instanceSet the underlyinginstancefield.- Returns:
- the same builder instance
 
- 
propertySet a "dynamic"propertyon the underlyingProblemDetail.- Returns:
- the same builder instance
 
- 
buildErrorResponse build()Build theErrorResponseinstance.
- 
buildBuild theErrorResponseinstance and also resolve the "detail" and "title" through the givenMessageSource. Effectively a shortcut for callingbuild()and thenErrorResponse.updateAndGetBody(MessageSource, Locale).- Since:
- 6.0.3
 
 
-