Top Description Inners Fields Constructors Methods
org.springframework.web

pack-priv final Class DefaultErrorResponseBuilder

extends Object
implements Builder
Class Inheritance
All Implemented Interfaces
org.springframework.web.ErrorResponse.Builder
Imports
java.net.URI, java.util.function.Consumer, org.springframework.http.HttpHeaders, .HttpStatusCode, .ProblemDetail, org.springframework.lang.Nullable, org.springframework.util.Assert

Default implementation of ErrorResponse.Builder.
Author
Rossen Stoyanchev
Since
6.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
DefaultErrorResponseBuilder.SimpleErrorResponse

Simple container for ErrorResponse values.

Field Summary

Modifier and TypeField and Description
private Object[]
private String
private final Throwable
private HttpHeaders
private final ProblemDetail
private final HttpStatusCode
private String
private String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public ErrorResponse
build()

Implements org.springframework.web.ErrorResponse.Builder.build.

Build the ErrorResponse instance.

public ErrorResponse.Builder
public ErrorResponse.Builder
detailMessageArguments(Object...
the arguments to provide
messageArguments
)

Implements org.springframework.web.ErrorResponse.Builder.detailMessageArguments.

Set the arguments to provide to the MessageSource lookup for detailMessageCode(String).

public ErrorResponse.Builder
detailMessageCode(String
the message code to use
messageCode
)

Implements org.springframework.web.ErrorResponse.Builder.detailMessageCode.

Customize the MessageSource code to use to resolve the value for the detail(String).

public ErrorResponse.Builder
header(String
the header name
headerName
,
String...
the header value(s)
headerValues
)

Implements org.springframework.web.ErrorResponse.Builder.header.

Add the given header value(s) under the given name.

public ErrorResponse.Builder
headers(Consumer<HttpHeaders>
a function that consumes the HttpHeaders
headersConsumer
)

Implements org.springframework.web.ErrorResponse.Builder.headers.

Manipulate this response's headers with the given consumer.

public ErrorResponse.Builder
instance(URI instance)

Implements org.springframework.web.ErrorResponse.Builder.instance.

Set the underlying instance field.

public ErrorResponse.Builder
property(String name, Object value)

Implements org.springframework.web.ErrorResponse.Builder.property.

Set a "dynamic" property on the underlying ProblemDetail.

public ErrorResponse.Builder
title(String title)

Implements org.springframework.web.ErrorResponse.Builder.title.

Set the underlying title field.

public ErrorResponse.Builder
titleMessageCode(String
the message code to use
messageCode
)

Implements org.springframework.web.ErrorResponse.Builder.titleMessageCode.

Customize the MessageSource code to use to resolve the value for ProblemDetail#setTitle(String).

public ErrorResponse.Builder
type(URI type)

Implements org.springframework.web.ErrorResponse.Builder.type.

Set the underlying type field.

public ErrorResponse.Builder
typeMessageCode(String
the message code to use
messageCode
)

Implements org.springframework.web.ErrorResponse.Builder.typeMessageCode.

Customize the MessageSource code to use to resolve the value for ProblemDetail#setType(URI).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

detailMessageArgumentsback to summary
private Object[] detailMessageArguments
Annotations
@Nullable
detailMessageCodeback to summary
private String detailMessageCode
exceptionback to summary
private final Throwable exception
headersback to summary
private HttpHeaders headers
Annotations
@Nullable
problemDetailback to summary
private final ProblemDetail problemDetail
statusCodeback to summary
private final HttpStatusCode statusCode
titleMessageCodeback to summary
private String titleMessageCode
typeMessageCodeback to summary
private String typeMessageCode

Constructor Detail

DefaultErrorResponseBuilderback to summary
pack-priv DefaultErrorResponseBuilder(Throwable ex, ProblemDetail problemDetail)

Method Detail

buildback to summary
public ErrorResponse build()

Implements org.springframework.web.ErrorResponse.Builder.build.

Doc from org.springframework.web.ErrorResponse.Builder.build.

Build the ErrorResponse instance.

Annotations
@Override
detailback to summary
public ErrorResponse.Builder detail(String detail)

Implements org.springframework.web.ErrorResponse.Builder.detail.

Doc from org.springframework.web.ErrorResponse.Builder.detail.

Set the underlying detail.

Returns:ErrorResponse.Builder

the same builder instance

Annotations
@Override
detailMessageArgumentsback to summary
public ErrorResponse.Builder detailMessageArguments(Object... messageArguments)

Implements org.springframework.web.ErrorResponse.Builder.detailMessageArguments.

Doc from org.springframework.web.ErrorResponse.Builder.detailMessageArguments.

Set the arguments to provide to the MessageSource lookup for detailMessageCode(String).

Parameters
messageArguments:Object[]

the arguments to provide

Returns:ErrorResponse.Builder

the same builder instance

Annotations
@Override
detailMessageCodeback to summary
public ErrorResponse.Builder detailMessageCode(String messageCode)

Implements org.springframework.web.ErrorResponse.Builder.detailMessageCode.

Doc from org.springframework.web.ErrorResponse.Builder.detailMessageCode.

Customize the MessageSource code to use to resolve the value for the detail(String).

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

Parameters
messageCode:String

the message code to use

Returns:ErrorResponse.Builder

the same builder instance

Annotations
@Override
headerback to summary
public ErrorResponse.Builder header(String headerName, String... headerValues)

Implements org.springframework.web.ErrorResponse.Builder.header.

Doc from org.springframework.web.ErrorResponse.Builder.header.

Add the given header value(s) under the given name.

Parameters
headerName:String

the header name

headerValues:String[]

the header value(s)

Returns:ErrorResponse.Builder

the same builder instance

Annotations
@Override
headersback to summary
public ErrorResponse.Builder headers(Consumer<HttpHeaders> headersConsumer)

Implements org.springframework.web.ErrorResponse.Builder.headers.

Doc from org.springframework.web.ErrorResponse.Builder.headers.

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:Consumer<HttpHeaders>

a function that consumes the HttpHeaders

Returns:ErrorResponse.Builder

the same builder instance

Annotations
@Override
instanceback to summary
public ErrorResponse.Builder instance(URI instance)

Implements org.springframework.web.ErrorResponse.Builder.instance.

Doc from org.springframework.web.ErrorResponse.Builder.instance.

Set the underlying instance field.

Returns:ErrorResponse.Builder

the same builder instance

Annotations
@Override
propertyback to summary
public ErrorResponse.Builder property(String name, Object value)

Implements org.springframework.web.ErrorResponse.Builder.property.

Doc from org.springframework.web.ErrorResponse.Builder.property.

Set a "dynamic" property on the underlying ProblemDetail.

Returns:ErrorResponse.Builder

the same builder instance

Annotations
@Override
titleback to summary
public ErrorResponse.Builder title(String title)

Implements org.springframework.web.ErrorResponse.Builder.title.

Doc from org.springframework.web.ErrorResponse.Builder.title.

Set the underlying title field.

Returns:ErrorResponse.Builder

the same builder instance

Annotations
@Override
titleMessageCodeback to summary
public ErrorResponse.Builder titleMessageCode(String messageCode)

Implements org.springframework.web.ErrorResponse.Builder.titleMessageCode.

Doc from org.springframework.web.ErrorResponse.Builder.titleMessageCode.

Customize the MessageSource code to use to resolve the value for ProblemDetail#setTitle(String).

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

Parameters
messageCode:String

the message code to use

Returns:ErrorResponse.Builder

the same builder instance

Annotations
@Override
typeback to summary
public ErrorResponse.Builder type(URI type)

Implements org.springframework.web.ErrorResponse.Builder.type.

Doc from org.springframework.web.ErrorResponse.Builder.type.

Set the underlying type field.

Returns:ErrorResponse.Builder

the same builder instance

Annotations
@Override
typeMessageCodeback to summary
public ErrorResponse.Builder typeMessageCode(String messageCode)

Implements org.springframework.web.ErrorResponse.Builder.typeMessageCode.

Doc from org.springframework.web.ErrorResponse.Builder.typeMessageCode.

Customize the MessageSource code to use to resolve the value for ProblemDetail#setType(URI).

By default, set from ErrorResponse#getDefaultTypeMessageCode(Class).

Parameters
messageCode:String

the message code to use

Returns:ErrorResponse.Builder

the same builder instance

Annotations
@Override
org.springframework.web back to summary

private Class DefaultErrorResponseBuilder.SimpleErrorResponse

extends Object
implements ErrorResponse
Class Inheritance
  • java.lang.Object
  • org.springframework.web.DefaultErrorResponseBuilder.SimpleErrorResponse
All Implemented Interfaces
org.springframework.web.ErrorResponse

Simple container for ErrorResponse values.

Field Summary

Modifier and TypeField and Description
private final Object[]
private final String
private final Throwable
private final HttpHeaders
private final ProblemDetail
private final HttpStatusCode
private final String
private final String

Constructor Summary

AccessConstructor and Description
pack-priv
SimpleErrorResponse(Throwable ex, HttpStatusCode statusCode, HttpHeaders headers, ProblemDetail problemDetail, String typeMessageCode, String titleMessageCode, String detailMessageCode, Object[] detailMessageArguments)

Method Summary

Modifier and TypeMethod and Description
public ProblemDetail
getBody()

Implements org.springframework.web.ErrorResponse.getBody.

Return the body for the response, formatted as an RFC 7807 ProblemDetail whose status should match the response status.

public Object[]
getDetailMessageArguments()

Overrides default org.springframework.web.ErrorResponse.getDetailMessageArguments.

Return arguments to use along with a message code to resolve the problem "detail" for this exception through a MessageSource.

public String
getDetailMessageCode()

Overrides default org.springframework.web.ErrorResponse.getDetailMessageCode.

Return a code to use to resolve the problem "detail" for this exception through a MessageSource.

public HttpHeaders
getHeaders()

Overrides default org.springframework.web.ErrorResponse.getHeaders.

Return headers to use for the response.

public HttpStatusCode
getStatusCode()

Implements org.springframework.web.ErrorResponse.getStatusCode.

Return the HTTP status code to use for the response.

public String
getTitleMessageCode()

Overrides default org.springframework.web.ErrorResponse.getTitleMessageCode.

Return a code to use to resolve the problem "title" for this exception through a MessageSource.

public String
getTypeMessageCode()

Overrides default org.springframework.web.ErrorResponse.getTypeMessageCode.

Return a code to use to resolve the problem "type" for this exception through a MessageSource.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

detailMessageArgumentsback to summary
private final Object[] detailMessageArguments
Annotations
@Nullable
detailMessageCodeback to summary
private final String detailMessageCode
exceptionback to summary
private final Throwable exception
headersback to summary
private final HttpHeaders headers
problemDetailback to summary
private final ProblemDetail problemDetail
statusCodeback to summary
private final HttpStatusCode statusCode
titleMessageCodeback to summary
private final String titleMessageCode
typeMessageCodeback to summary
private final String typeMessageCode

Constructor Detail

SimpleErrorResponseback to summary
pack-priv SimpleErrorResponse(Throwable ex, HttpStatusCode statusCode, HttpHeaders headers, ProblemDetail problemDetail, String typeMessageCode, String titleMessageCode, String detailMessageCode, Object[] detailMessageArguments)

Method Detail

getBodyback to summary
public ProblemDetail getBody()

Implements org.springframework.web.ErrorResponse.getBody.

Doc from org.springframework.web.ErrorResponse.getBody.

Return the body for the response, formatted as an RFC 7807 ProblemDetail whose status should match the response status.

Annotations
@Override
getDetailMessageArgumentsback to summary
public Object[] getDetailMessageArguments()

Overrides default org.springframework.web.ErrorResponse.getDetailMessageArguments.

Doc from org.springframework.web.ErrorResponse.getDetailMessageArguments.

Return arguments to use along with a message code to resolve the problem "detail" for this exception through a MessageSource. The arguments are expanded into placeholders of the message value, e.g. "Invalid content type {0}".

Annotations
@Override
getDetailMessageCodeback to summary
public String getDetailMessageCode()

Overrides default org.springframework.web.ErrorResponse.getDetailMessageCode.

Doc from org.springframework.web.ErrorResponse.getDetailMessageCode.

Return a code to use to resolve the problem "detail" for this exception through a MessageSource.

By default this is initialized via getDefaultDetailMessageCode(Class, String).

Annotations
@Override
getHeadersback to summary
public HttpHeaders getHeaders()

Overrides default org.springframework.web.ErrorResponse.getHeaders.

Doc from org.springframework.web.ErrorResponse.getHeaders.

Return headers to use for the response.

Annotations
@Override
getStatusCodeback to summary
public HttpStatusCode getStatusCode()

Implements org.springframework.web.ErrorResponse.getStatusCode.

Doc from org.springframework.web.ErrorResponse.getStatusCode.

Return the HTTP status code to use for the response.

Annotations
@Override
getTitleMessageCodeback to summary
public String getTitleMessageCode()

Overrides default org.springframework.web.ErrorResponse.getTitleMessageCode.

Doc from org.springframework.web.ErrorResponse.getTitleMessageCode.

Return a code to use to resolve the problem "title" for this exception through a MessageSource.

By default this is initialized via getDefaultTitleMessageCode(Class).

Annotations
@Override
getTypeMessageCodeback to summary
public String getTypeMessageCode()

Overrides default org.springframework.web.ErrorResponse.getTypeMessageCode.

Doc from org.springframework.web.ErrorResponse.getTypeMessageCode.

Return a code to use to resolve the problem "type" for this exception through a MessageSource. The type resolved through the MessageSource will be passed into URI#create(String) and therefore must be an encoded URI String.

By default this is initialized via getDefaultTypeMessageCode(Class).

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override