Top Description Fields Constructors Methods
org.springframework.messaging.support

public Class ErrorMessage

extends GenericMessage<Throwable>
Class Inheritance
Imports
java.util.Map, org.springframework.lang.Nullable, org.springframework.messaging.Message, .MessageHeaders

A GenericMessage with a Throwable payload.

The payload is typically a org.springframework.messaging.MessagingException with the message at the point of failure in its failedMessage property. An optional originalMessage may be provided, which represents the message that existed at the point in the stack where the error message is created.

Consider some code that starts with a message, invokes some process that performs transformation on that message and then fails for some reason, throwing the exception. The exception is caught and an error message produced that contains both the original message, and the transformed message that failed.

Authors
Mark Fisher, Oleg Zhurakousky, Gary Russell
Since
4.0
See Also
MessageBuilder

Field Summary

Modifier and TypeField and Description
private final Message<?>
private static final long

Constructor Summary

AccessConstructor and Description
public
ErrorMessage(Throwable
the message payload (never null)
payload
)

Create a new message with the given payload.

public
ErrorMessage(Throwable
the message payload (never null)
payload
,
Map<String, Object>
message headers to use for initialization
headers
)

Create a new message with the given payload and headers.

public
ErrorMessage(Throwable
the message payload (never null)
payload
,
MessageHeaders
message headers
headers
)

A constructor with the MessageHeaders instance to use.

public
ErrorMessage(Throwable
the message payload (never null)
payload
,
Message<?>
the original message (if present) at the point in the stack where the ErrorMessage was created
originalMessage
)

Create a new message with the given payload and original message.

public
ErrorMessage(Throwable
the message payload (never null)
payload
,
Map<String, Object>
message headers to use for initialization
headers
,
Message<?>
the original message (if present) at the point in the stack where the ErrorMessage was created
originalMessage
)

Create a new message with the given payload, headers and original message.

public
ErrorMessage(Throwable
the message payload (never null)
payload
,
MessageHeaders
message headers
headers
,
Message<?>
the original message (if present) at the point in the stack where the ErrorMessage was created
originalMessage
)

Create a new message with the payload, MessageHeaders and original message.

Method Summary

Modifier and TypeMethod and Description
public Message<?>
getOriginalMessage()

Return the original message (if available) at the point in the stack where the ErrorMessage was created.

public String
toString()

Overrides org.springframework.messaging.support.GenericMessage.toString.

Returns a string representation of the object.

Inherited from org.springframework.messaging.support.GenericMessage:
equalsgetHeadersgetPayloadhashCode

Field Detail

originalMessageback to summary
private final Message<?> originalMessage
Annotations
@Nullable
@SuppressWarnings:serial
serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.springframework.messaging.support.GenericMessage.serialVersionUID.

Constructor Detail

ErrorMessageback to summary
public ErrorMessage(Throwable payload)

Create a new message with the given payload.

Parameters
payload:Throwable

the message payload (never null)

ErrorMessageback to summary
public ErrorMessage(Throwable payload, Map<String, Object> headers)

Create a new message with the given payload and headers. The content of the given header map is copied.

Parameters
payload:Throwable

the message payload (never null)

headers:Map<String, Object>

message headers to use for initialization

ErrorMessageback to summary
public ErrorMessage(Throwable payload, MessageHeaders headers)

A constructor with the MessageHeaders instance to use.

Note

the given MessageHeaders instance is used directly in the new message, i.e. it is not copied.

Parameters
payload:Throwable

the message payload (never null)

headers:MessageHeaders

message headers

ErrorMessageback to summary
public ErrorMessage(Throwable payload, Message<?> originalMessage)

Create a new message with the given payload and original message.

Parameters
payload:Throwable

the message payload (never null)

originalMessage:Message<?>

the original message (if present) at the point in the stack where the ErrorMessage was created

Since
5.0
ErrorMessageback to summary
public ErrorMessage(Throwable payload, Map<String, Object> headers, Message<?> originalMessage)

Create a new message with the given payload, headers and original message. The content of the given header map is copied.

Parameters
payload:Throwable

the message payload (never null)

headers:Map<String, Object>

message headers to use for initialization

originalMessage:Message<?>

the original message (if present) at the point in the stack where the ErrorMessage was created

Since
5.0
ErrorMessageback to summary
public ErrorMessage(Throwable payload, MessageHeaders headers, Message<?> originalMessage)

Create a new message with the payload, MessageHeaders and original message.

Note

the given MessageHeaders instance is used directly in the new message, i.e. it is not copied.

Parameters
payload:Throwable

the message payload (never null)

headers:MessageHeaders

message headers

originalMessage:Message<?>

the original message (if present) at the point in the stack where the ErrorMessage was created

Since
5.0

Method Detail

getOriginalMessageback to summary
public Message<?> getOriginalMessage()

Return the original message (if available) at the point in the stack where the ErrorMessage was created.

Annotations
@Nullable
Since
5.0
toStringback to summary
public String toString()

Overrides org.springframework.messaging.support.GenericMessage.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