Package org.springframework.web
Interface ErrorResponse.Builder
- Enclosing interface:
- ErrorResponse
public static interface ErrorResponse.Builder
Builder for an
ErrorResponse
.-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build theErrorResponse
instance.default ErrorResponse
build
(MessageSource messageSource, Locale locale) Build theErrorResponse
instance and also resolve the "detail" and "title" through the givenMessageSource
.Set the underlyingdetail
.detailMessageArguments
(Object... messageArguments) Set the arguments to provide to theMessageSource
lookup fordetailMessageCode(String)
.detailMessageCode
(String messageCode) Customize theMessageSource
code to use to resolve the value for thedetail(String)
.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 underlyinginstance
field.Set a "dynamic"property
on the underlyingProblemDetail
.Set the underlyingtitle
field.titleMessageCode
(String messageCode) Customize theMessageSource
code to use to resolve the value forProblemDetail.setTitle(String)
.Set the underlyingtype
field.typeMessageCode
(String messageCode) Customize theMessageSource
code to use to resolve the value forProblemDetail.setType(URI)
.
-
Method Details
-
header
Add the given header value(s) under the given name.- Parameters:
headerName
- the header nameheaderValues
- the header value(s)- Returns:
- the same builder instance
- See Also:
-
headers
Manipulate this response's headers with the given consumer. This is useful to overwrite or remove existing values, or use any otherHttpHeaders
methods.- Parameters:
headersConsumer
- a function that consumes theHttpHeaders
- Returns:
- the same builder instance
-
type
Set the underlyingtype
field.- Returns:
- the same builder instance
-
typeMessageCode
Customize theMessageSource
code to use to resolve the value forProblemDetail.setType(URI)
.By default, set from
ErrorResponse.getDefaultTypeMessageCode(Class)
.- Parameters:
messageCode
- the message code to use- Returns:
- the same builder instance
- Since:
- 6.1
- See Also:
-
title
Set the underlyingtitle
field.- Returns:
- the same builder instance
-
titleMessageCode
Customize theMessageSource
code to use to resolve the value forProblemDetail.setTitle(String)
.By default, set from
ErrorResponse.getDefaultTitleMessageCode(Class)
.- Parameters:
messageCode
- the message code to use- Returns:
- the same builder instance
- See Also:
-
instance
Set the underlyinginstance
field.- Returns:
- the same builder instance
-
detail
Set the underlyingdetail
.- Returns:
- the same builder instance
-
detailMessageCode
Customize theMessageSource
code to use to resolve the value for thedetail(String)
.By default, set from
ErrorResponse.getDefaultDetailMessageCode(Class, String)
.- Parameters:
messageCode
- the message code to use- Returns:
- the same builder instance
- See Also:
-
detailMessageArguments
Set the arguments to provide to theMessageSource
lookup fordetailMessageCode(String)
.- Parameters:
messageArguments
- the arguments to provide- Returns:
- the same builder instance
- See Also:
-
property
Set a "dynamic"property
on the underlyingProblemDetail
.- Returns:
- the same builder instance
-
build
ErrorResponse build()Build theErrorResponse
instance. -
build
Build theErrorResponse
instance and also resolve the "detail" and "title" through the givenMessageSource
. Effectively a shortcut for callingbuild()
and thenErrorResponse.updateAndGetBody(MessageSource, Locale)
.- Since:
- 6.0.3
-