Package org.springframework.web

# Interface ErrorResponse.Builder

Enclosing interface:
  ErrorResponse

public static interface ErrorResponse.Builder
Builder for an `ErrorResponse`.

## Method Summary

Modifier and Type
Method
Description
`ErrorResponse`
`build()`
Build the `ErrorResponse` instance.
`default ErrorResponse`
`build(org.springframework.context.MessageSource messageSource, Locale locale)`
Build the `ErrorResponse` instance and also resolve the "detail" and "title" through the given `MessageSource`.
`ErrorResponse.Builder`
`detail(String detail)`
Set the underlying `detail`.
`ErrorResponse.Builder`
`detailMessageArguments(Object... messageArguments)`
Set the arguments to provide to the `MessageSource` lookup for `detailMessageCode(String)`.
`ErrorResponse.Builder`
`detailMessageCode(String messageCode)`
Customize the `MessageSource` code to use to resolve the value for the `detail(String)`.
`ErrorResponse.Builder`
`header(String headerName, String... headerValues)`
Add the given header value(s) under the given name.
`ErrorResponse.Builder`
`headers(Consumer<HttpHeaders> headersConsumer)`
Manipulate this response's headers with the given consumer.
`ErrorResponse.Builder`
`instance(URI instance)`
Set the underlying `instance` field.
`ErrorResponse.Builder`
`property(String name, Object value)`
Set a "dynamic" `property` on the underlying `ProblemDetail`.
`ErrorResponse.Builder`
`title(String title)`
Set the underlying `title` field.
`ErrorResponse.Builder`
`titleMessageCode(String messageCode)`
Customize the `MessageSource` code to use to resolve the value for `ProblemDetail.setTitle(String)`.
`ErrorResponse.Builder`
`type(URI type)`
Set the underlying `type` field.
`ErrorResponse.Builder`
`typeMessageCode(String messageCode)`
Customize the `MessageSource` code to use to resolve the value for `ProblemDetail.setType(URI)`.

## Method Details

### header

ErrorResponse.Builder header(String headerName, String... headerValues)
Add 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:
  - `HttpHeaders.add(String, String)`

### headers

ErrorResponse.Builder headers(Consumer<HttpHeaders> headersConsumer)
Manipulate this response's headers with the given consumer. This is useful to overwrite or remove existing values, or use any other `HttpHeaders` methods.

Parameters:
  `headersConsumer` - a function that consumes the `HttpHeaders`
Returns:
  the same builder instance

### type

ErrorResponse.Builder type(URI type)
Set the underlying `type` field.

Returns:
  the same builder instance

### typeMessageCode

ErrorResponse.Builder typeMessageCode(String messageCode)
Customize the `MessageSource` code to use to resolve the value for `ProblemDetail.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:
  - `ErrorResponse.getTypeMessageCode()`

### title

ErrorResponse.Builder title(@Nullable String title)
Set the underlying `title` field.

Returns:
  the same builder instance

### titleMessageCode

ErrorResponse.Builder titleMessageCode(String messageCode)
Customize the `MessageSource` code to use to resolve the value for `ProblemDetail.setTitle(String)`.

By default, set from `ErrorResponse.getDefaultTitleMessageCode(Class)`.

Parameters:
  `messageCode` - the message code to use
Returns:
  the same builder instance
See Also:
  - `ErrorResponse.getTitleMessageCode()`

### instance

ErrorResponse.Builder instance(@Nullable URI instance)
Set the underlying `instance` field.

Returns:
  the same builder instance

### detail

ErrorResponse.Builder detail(String detail)
Set the underlying `detail`.

Returns:
  the same builder instance

### detailMessageCode

ErrorResponse.Builder detailMessageCode(String messageCode)
Customize the `MessageSource` code to use to resolve the value for the `detail(String)`.

By default, set from `ErrorResponse.getDefaultDetailMessageCode(Class, String)`.

Parameters:
  `messageCode` - the message code to use
Returns:
  the same builder instance
See Also:
  - `ErrorResponse.getDetailMessageCode()`

### detailMessageArguments

ErrorResponse.Builder detailMessageArguments(Object... messageArguments)
Set the arguments to provide to the `MessageSource` lookup for `detailMessageCode(String)`.

Parameters:
  `messageArguments` - the arguments to provide
Returns:
  the same builder instance
See Also:
  - `ErrorResponse.getDetailMessageArguments()`

### property

ErrorResponse.Builder property(String name, @Nullable Object value)
Set a "dynamic" `property` on the underlying `ProblemDetail`.

Returns:
  the same builder instance

### build

ErrorResponse build()
Build the `ErrorResponse` instance.

### build

default ErrorResponse build(@Nullable org.springframework.context.MessageSource messageSource, Locale locale)
Build the `ErrorResponse` instance and also resolve the "detail" and "title" through the given `MessageSource`. Effectively a shortcut for calling `build()` and then `ErrorResponse.updateAndGetBody(MessageSource, Locale)`.

Since:
  6.0.3